I was reading the book. In detail about "On to Own Unidirectional", the author has written the following Customer
, address
example:
@Entity Public Class Customer { @ ID @ Generated Values Private Long ID; The name of the private string; Private address addresses; // some other columns, gates / sets} @ anti public class address {@Id @GeneratedValue Private Long ID; Private string city; // some other columns, gates / sets}
and were saying -
- This is the required minimum annotation.
- No on toon annotation is required. (Because, by default, persistence provider will accept it)
- @Joint column annotation allows you to customize the mapping of a foreign key. As shown below, we can rename the foreign key column for ADD_FK
and then about it:
@Entity Public Class customer {@Id @ generatedValue Private Long ID; The name of the private string; @OneToOne @JoinColumn (name = "ADD_FK") Private address addresses; // some other columns, gates / sets} @interity public class order {.... list & lt; Orderline & gt; Periods; ...}
- OneTyMany connection is assumed by default when a type of entity is being used in the collection.
My question:
-
Is the above statement valid? Because when I try these examples on Hibernate, I was getting an exception.
-
What details are made according to JPA standards?
- Or is it that Hibernation is implemented differently?
Please clarify.
For my knowledge, there should be a connection between institutions obviously From the mapped JPA 1.0 specification (bold mine):
2.1.7 Organization relationships
Relationships between entities are one-to-one, one-to-many Many, many-to-one, or many-to-many relationships are polymorphic.
If there is a connection between the two entities, then the following relation should be one of the modeling annotations refers to the area of the referenced unit or the corresponding referenced unit:
OneToOne
,OneToMany
,too many a
,ManyToMany
. For those organizations who do not specify the target type (for example, where Java is not used for normal type of collection), it is necessary to specify an organization that is the goal of the relationship.(...)
And it did not convert to JPA 2.0.
I thus explain the relationship between institutions. And AAPAI, Hibernate will actually complain that when it does not, then a complex type is not being able to continue.
But unless I can show any specific details, then I treat the behavior as right.
Reference
- JPA 1.0 specification
- Section 2.1.7 "Entity Relationships"
- JPA 2.0 specification
- Section 2. 9 "Entity Relationships"
Comments
Post a Comment