• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does @CollectionTable do ?

 
Sreyan Chakravarty
Ranch Hand
Posts: 65
Firefox Browser MyEclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone explain what does the @CollectionTable annotation do ?

Can someone please explain the following code snippet -:



I found it over here http://www.java2s.com/Tutorials/Java/JPA/0340__JPA_ElementCollection_CollectionTable_Override.htm

What would happen if I did not add the @CollectionTable annotation ? Why must I use it ?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I have a doubt about JPA, I always check the Java Persistence Wikibook first. Most of the time my doubts are cleared, it's really an awesome resource! Here is the page about ElementCollection (and @CollectionTable).
 
Sreyan Chakravarty
Ranch Hand
Posts: 65
Firefox Browser MyEclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:When I have a doubt about JPA, I always check the Java Persistence Wikibook first. Most of the time my doubts are cleared, it's really an awesome resource! Here is the page about ElementCollection (and @CollectionTable).


So the @CollectionTable annotation specifies the name of the mapping table and the join column for an @ElementCollection type of mapping ? Correct me if I am wrong.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sreyan Chakravarty wrote:So the @CollectionTable annotation specifies the name of the mapping table and the join column for an @ElementCollection type of mapping ? Correct me if I am wrong.

Yes indeed! You can also have a look at the javadoc of the annotation if are unsure. It contains most of the times some useful examples as well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic