Hibernate mapping without a class reference?

Posted on 2009-05-01
Last Modified: 2013-11-24
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?
Question by:justsomeguy1
    1 Comment
    LVL 12

    Accepted Solution

    Extending Rating class is the only solution I think.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Title # Comments Views Activity
    Error when connecting to oracle 11g via access 2013 18 47
    Convert BufferedReader to File 1 49
    .csv files 5 62
    array6 challenfge 6 48
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now