2

I have a few tables in my database

User (userid, password roleid) Role ( roleid, actionid) Action ( actionid, action)

I need to join this three tables together, base on the roleid from the user, i will get the roleid and from there do a one to many relation with Action.

I been reading on some of the examples online but all i could find is examples on joining 2 tables.

Is it possible to join all these three up using just one .hbm file?

1 Answer 1

2

You seem to have a many-to-many association:

  • a user has several actions
  • an action can be done by several users

many to many associations, as all the other kinds of associations, are described in the reference documentation:

http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#assoc-unidirectional-join-m2m

http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#assoc-bidirectional-join-m2m

I personally find annotations much more easy and developer-friendly than XML files. Consider using annotations rather than XML. Moreover, annotations are standard JPA annotations, and are the same for all the JPA implementations. They're a good thing to know.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.