[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4529?page=c...
]
Steve Ebersole updated HHH-4529:
--------------------------------
Description:
2.4.1.1
IdClass (derived side)
"The names of the attributes of the id class and the Id attributes of the dependent
entity class
must correspond as follows:
• The Id attribute in the entity class and the corresponding attribute in the id class
must
have the same name.
• If an Id attribute in the entity class is of basic type, the corresponding attribute in
the
id class must have the same type.
• If an Id attribute in the entity is a many-to-one or one-to-one relationship to a parent
entity, the corresponding attribute in the id class must be of the same Java type as the
id class or embedded id of the parent entity (if the parent entity has a composite pri-
mary key) or the type of the Id attribute of the parent entity (if the parent entity has a
simple primary key). "
This basically mean that property names int he entity and idClass must match. Types should
be identical unless a @Id @XToOne Parent parent; is present in the entity. In this case
the corresponding IdClass property should be of the type of the Parent PK
"Alternatively, If the dependent entity has a single primary key attribute (i.e., the
relationship attribute), the id
class specified by the dependent entity must be the same as the primary key class of the
parent
entity. The Id annotation is applied to the relationship to the parent entity."
"If the dependent entity uses an embedded id to represent its primary key, the
attribute in the embedded
id corresponding to the relationship attribute must be of the same type as the primary key
of the parent
entity and must be designated by the MapsId annotation applied to the relationship
attribute. The
value element of the MapsId annotation must be used to specify the name of the attribute
within the
embedded id to which the relationship attribute corresponds. If the embedded id of the
dependent entity
is of the same Java type as the primary key of the parent entity, the relationship
attribute maps both the
relationship to the parent and the primary key of the dependent entity, and in this case
the MapsId
annotation is specified without the value element."
class Person
@Id PersonPK id;
@MapsId("ssnId") @ManyToOne SSN ssn;
static class PersonPK {
String name;
String ssnId;
}
}
class SSN {
@Id String id;
}
"If the dependent entity has a single primary key attribute (i.e, the relationship
attribute or an attribute
that corresponds to the relationship attribute) and the primary key of the parent entity
is a simple pri-
mary key, the primary key of the dependent entity is a simple primary key of the same type
as that of the
parent entity (and neither EmbeddedId nor IdClass is specified). In this case, either (1)
the rela-
tionship attribute is annotated Id, or (2) a separate Id attribute is specified and the
relationship attribute
is annotated MapsId (and the value element of the MapsId annotation is not
specified)"
"A primary key attribute that is derived from the identity of a parent entity is
mapped by the correspond-
ing relationship attribute. The default mapping for this relationship is as specified in
section 2.10. In
the case where a default mapping does not apply or where a default mapping is to be
overridden, the
JoinColumn or JoinColumns annotation is used on the relationship attribute.
If the dependent entity uses an embedded id to represent its primary key, the
AttributeOverride
annotation may be used to override the default mapping of embedded id attributes that do
not corre-
spond to the relationship attributes mapping the derived identity. The embedded id
attributes that cor-
respond to the relationship are treated by the provider as "read only"—that is,
any updates to them on
the part of the application are not propagated to the database.
If the dependent uses an id class, the Column annotation may be used to override the
default mapping
of Id attributes that are not relationship attributes. "
Examples for all that on page 31
was:
2.4.1.1
IdClass (derived side)
"The names of the attributes of the id class and the Id attributes of the dependent
entity class
must correspond as follows:
• The Id attribute in the entity class and the corresponding attribute in the id class
must
have the same name.
• If an Id attribute in the entity class is of basic type, the corresponding attribute in
the
id class must have the same type.
• If an Id attribute in the entity is a many-to-one or one-to-one relationship to a parent
entity, the corresponding attribute in the id class must be of the same Java type as the
id class or embedded id of the parent entity (if the parent entity has a composite pri-
mary key) or the type of the Id attribute of the parent entity (if the parent entity has a
simple primary key). "
This basically mean that property names int he entity and idClass must match. Types should
be identical unless a @Id @XToOne Parent parent; is present in the entity. In this case
the corresponding IdClass property should be of the type of the Parent PK
"Alternatively, If the dependent entity has a single primary key attribute (i.e., the
relationship attribute), the id
class specified by the dependent entity must be the same as the primary key class of the
parent
entity. The Id annotation is applied to the relationship to the parent entity."
"If the dependent entity uses an embedded id to represent its primary key, the
attribute in the embedded
id corresponding to the relationship attribute must be of the same type as the primary key
of the parent
entity and must be designated by the MapsId annotation applied to the relationship
attribute. The
value element of the MapsId annotation must be used to specify the name of the attribute
within the
embedded id to which the relationship attribute corresponds. If the embedded id of the
dependent entity
is of the same Java type as the primary key of the parent entity, the relationship
attribute maps both the
relationship to the parent and the primary key of the dependent entity, and in this case
the MapsId
annotation is specified without the value element."
class Person
@Id PersonPK id;
@MapsId("ssnId") @ManyToOne SSN ssn;
static class PersonPK {
String name;
String ssnId;
}
}
class SSN {
@Id String id;
}
"If the dependent entity has a single primary key attribute (i.e, the relationship
attribute or an attribute
that corresponds to the relationship attribute) and the primary key of the parent entity
is a simple pri-
mary key, the primary key of the dependent entity is a simple primary key of the same type
as that of the
parent entity (and neither EmbeddedId nor IdClass is specified). In this case, either (1)
the rela-
tionship attribute is annotated Id, or (2) a separate Id attribute is specified and the
relationship attribute
is annotated MapsId (and the value element of the MapsId annotation is not
specified)"
"A primary key attribute that is derived from the identity of a parent entity is
mapped by the correspond-
ing relationship attribute. The default mapping for this relationship is as specified in
section 2.10. In
the case where a default mapping does not apply or where a default mapping is to be
overridden, the
JoinColumn or JoinColumns annotation is used on the relationship attribute.
If the dependent entity uses an embedded id to represent its primary key, the
AttributeOverride
annotation may be used to override the default mapping of embedded id attributes that do
not corre-
spond to the relationship attributes mapping the derived identity. The embedded id
attributes that cor-
respond to the relationship are treated by the provider as "read only"—that is,
any updates to them on
the part of the application are not propagated to the database.
If the dependent uses an id class, the Column annotation may be used to override the
default mapping
of Id attributes that are not relationship attributes. "
Examples for all that on page 31
Fix Version/s: (was: 3.5)
3.5.0-Beta-4
Support for derived identity (including @MapsId)
------------------------------------------------
Key: HHH-4529
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4529
Project: Hibernate Core
Issue Type: Sub-task
Components: annotations
Reporter: Emmanuel Bernard
Assignee: Emmanuel Bernard
Fix For: 3.5.0-Beta-4
Attachments: HHH-4529-2.patch, HHH-4529.patch
2.4.1.1
IdClass (derived side)
"The names of the attributes of the id class and the Id attributes of the dependent
entity class
must correspond as follows:
• The Id attribute in the entity class and the corresponding attribute in the id class
must
have the same name.
• If an Id attribute in the entity class is of basic type, the corresponding attribute in
the
id class must have the same type.
• If an Id attribute in the entity is a many-to-one or one-to-one relationship to a
parent
entity, the corresponding attribute in the id class must be of the same Java type as the
id class or embedded id of the parent entity (if the parent entity has a composite pri-
mary key) or the type of the Id attribute of the parent entity (if the parent entity has
a
simple primary key). "
This basically mean that property names int he entity and idClass must match. Types
should be identical unless a @Id @XToOne Parent parent; is present in the entity. In this
case the corresponding IdClass property should be of the type of the Parent PK
"Alternatively, If the dependent entity has a single primary key attribute (i.e.,
the relationship attribute), the id
class specified by the dependent entity must be the same as the primary key class of the
parent
entity. The Id annotation is applied to the relationship to the parent entity."
"If the dependent entity uses an embedded id to represent its primary key, the
attribute in the embedded
id corresponding to the relationship attribute must be of the same type as the primary
key of the parent
entity and must be designated by the MapsId annotation applied to the relationship
attribute. The
value element of the MapsId annotation must be used to specify the name of the attribute
within the
embedded id to which the relationship attribute corresponds. If the embedded id of the
dependent entity
is of the same Java type as the primary key of the parent entity, the relationship
attribute maps both the
relationship to the parent and the primary key of the dependent entity, and in this case
the MapsId
annotation is specified without the value element."
class Person
@Id PersonPK id;
@MapsId("ssnId") @ManyToOne SSN ssn;
static class PersonPK {
String name;
String ssnId;
}
}
class SSN {
@Id String id;
}
"If the dependent entity has a single primary key attribute (i.e, the relationship
attribute or an attribute
that corresponds to the relationship attribute) and the primary key of the parent entity
is a simple pri-
mary key, the primary key of the dependent entity is a simple primary key of the same
type as that of the
parent entity (and neither EmbeddedId nor IdClass is specified). In this case, either
(1) the rela-
tionship attribute is annotated Id, or (2) a separate Id attribute is specified and the
relationship attribute
is annotated MapsId (and the value element of the MapsId annotation is not
specified)"
"A primary key attribute that is derived from the identity of a parent entity is
mapped by the correspond-
ing relationship attribute. The default mapping for this relationship is as specified in
section 2.10. In
the case where a default mapping does not apply or where a default mapping is to be
overridden, the
JoinColumn or JoinColumns annotation is used on the relationship attribute.
If the dependent entity uses an embedded id to represent its primary key, the
AttributeOverride
annotation may be used to override the default mapping of embedded id attributes that do
not corre-
spond to the relationship attributes mapping the derived identity. The embedded id
attributes that cor-
respond to the relationship are treated by the provider as "read only"—that is,
any updates to them on
the part of the application are not propagated to the database.
If the dependent uses an id class, the Column annotation may be used to override the
default mapping
of Id attributes that are not relationship attributes. "
Examples for all that on page 31
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira