This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Many to many self join using hibernate annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Many to many self join using hibernate annotation" Watch "Many to many self join using hibernate annotation" New topic
Author

Many to many self join using hibernate annotation

Muhammad Ramahy
Greenhorn

Joined: Jun 14, 2011
Posts: 11

Hello, I want to create a self join many to many relation like in twitter user and follower where follower could follow many users and user could have many followers

so in the User Entity I put it like this


and in the database I have two tables:
User
username(ID)
password
email

user_follower
username(ID)
follower(ID)

the problem is that I get this exception:

The problem is that I don't know where the exception is thrown as my tomcat couldn't be initialized in debug mode but that's another issue
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

org.hibernate.LazyInitializationException

Have you searched for the documentation of this Exception? Because there is a lot of documentation about it.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
 
subject: Many to many self join using hibernate annotation