• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • 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 GeorgeCTOCommented:
Extending Rating class is the only solution I think.

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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