• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

Hibernate mapping without a class reference?

One limitation I discovered with my queries is that HQL will not let me use 'inner join on x', because it expects to discover the joined column through its own mapping files.

Say I have a very generic class like a Rating, which may be applied to comments, or submissions, or images ect. It makes sense for Rating to be reusable. However, I wouldn't want the Rating class to have a reference back to the other classes that might use it, for instance I wouldn't want references like Comment comment, Submission submission, when it makes more sense for it to have something like: private long referenceId; which could refer to any object.

Is there any wap to map a class without having a reference to the class, instead telling hibernate to just use the referenceId? Or is the correct and only solution to extend the Rating class whenever I need it, and make classes like CommentRating, SubmissionRating, which can be mapped normally?
1 Solution
Gibu GeorgeChief Technology OfficerCommented:
Extending Rating class is the only solution I think.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now