File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Values defaulted from the attribute?

 
Jayr Motta
Ranch Hand
Posts: 110
Google App Engine Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm studying for the JPA certification and I read this sentence in the book that I'm reading: "Ownership is important for mapping because the physical annotations that define the mappings to the columns in the database (for example, @JoinColumn) are always defined on the owning side of the relationship. If they are not there, the values are defaulted from the perspective of the attribute on the owning side."

I could not get the meaning of the last part, someone have an idea about what it could be?
 
James Sutherland
Ranch Hand
Posts: 553
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ownership is determined by usage of the "mappedBy" attribute.

If you use the mappedBy, it means the other side of the relationship owns the relationship, and will define the foreign key or join table.

For example in a ManyToMany one side will own the relationship and the other will use mappedBy. The name of the join table will be defined by the owning side, i.e. its name will come first, i.e. if Employee owned the relationship to Project, the table would be "EMP_PROJ" not "PROJ_EMP".

Or for a OneToOne, the side without the mappedBy will define the foreign key, the other side will not have a foreign key.
 
Jayr Motta
Ranch Hand
Posts: 110
Google App Engine Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,

I do understand what ownership of a relationship works, the doubt isn't about it and thus about "the values are defaulted from the perspective of the attribute on the owning side.", sorry if I was not clear from the get-go.

Thanks in advance!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic