From hibernate-commits at lists.jboss.org Mon Mar 8 13:24:20 2010 Content-Type: multipart/mixed; boundary="===============3687617456052002360==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r18934 - core/trunk/annotations/src/main/docbook/en/modules. Date: Mon, 08 Mar 2010 13:24:20 -0500 Message-ID: <201003081824.o28IOKD5005001@svn01.web.mwc.hst.phx2.redhat.com> --===============3687617456052002360== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: epbernard Date: 2010-03-08 13:24:20 -0500 (Mon, 08 Mar 2010) New Revision: 18934 Modified: core/trunk/annotations/src/main/docbook/en/modules/additionalmodules.xml core/trunk/annotations/src/main/docbook/en/modules/entity.xml core/trunk/annotations/src/main/docbook/en/modules/setup.xml core/trunk/annotations/src/main/docbook/en/modules/xml-overriding.xml Log: HHH-4933 use jHighlighter to align with core Modified: core/trunk/annotations/src/main/docbook/en/modules/additionalmodu= les.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/main/docbook/en/modules/additionalmodules.xm= l 2010-03-08 17:56:55 UTC (rev 18933) +++ core/trunk/annotations/src/main/docbook/en/modules/additionalmodules.xm= l 2010-03-08 18:24:20 UTC (rev 18934) @@ -122,7 +122,7 @@ ddl together by setting the property to callback, dll = - <persistence ...> + <persistence ...&= gt; <persistence-unit ...> ... <properties> @@ -171,15 +171,15 @@ Using custom groups for validation = - <persistence ...> + <persistence ...&= gt; <persistence-unit ...> ... <properties> - <property name=3D"javax.persistence.validation.group.pre= -update" + <property name=3D"javax.persistence.validation.group.pre-update" value=3D"javax.validation.group.Default, com.acme.group.St= rict"/> - <property name=3D"javax.persistence.validation.group.pre= -remove" + <property name=3D"javax.persistence.validation.group.pre-remove" value=3D"com.acme.group.OnDelete"/> - <property name=3D"org.hibernate.validator.group.ddl" + <property name=3D"org.hibernate.validator.group.ddl" value=3D"com.acme.group.DDL"/> </properties> </persistence-unit> Modified: core/trunk/annotations/src/main/docbook/en/modules/entity.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/main/docbook/en/modules/entity.xml 2010-03-0= 8 17:56:55 UTC (rev 18933) +++ core/trunk/annotations/src/main/docbook/en/modules/entity.xml 2010-03-0= 8 18:24:20 UTC (rev 18934) @@ -63,7 +63,7 @@ Every persistent POJO class is an entity and is declared using= the @Entity annotation (at the class level): = - @Entity + @Entity public class Flight implements Serializable { Long id; = @@ -102,7 +102,7 @@ mapping. If no @Table is defined the default va= lues are used: the unqualified class name of the entity. = - @Entity + @Entity @Table(name=3D"tbl_sky") public class Sky implements Serializable { ... @@ -117,8 +117,8 @@ @Column.unique approach (refer to @Column for more information). = - @Table(name=3D"tbl_sky", - uniqueConstraints =3D {@UniqueConstraint(colum= nNames=3D{"month", "day"})} + @Table(name=3D"tbl= _sky", + uniqueConstraints =3D {@UniqueConstraint(columnNames=3D{"month", "day"= })} ) = A unique constraint is applied to the tuple month, day. Note @@ -142,7 +142,7 @@ You can add optimistic locking capability to an entity using= the @Version annotation: = - @Entity + @Entity public class Flight implements Serializable { ... @Version @@ -182,7 +182,7 @@ annotation allows you to declare the fetching strategy for a property: = - public transient int counter; //transient property + public transient i= nt counter; //transient property = private String firstname; //persistent property = @@ -252,7 +252,7 @@ byte[] and serializable type will be persis= ted in a Blob. = - + @Lob public String getFullText() { return fullText; @@ -313,7 +313,7 @@ To force the access type on a given class, use the @Access annotation as showed below: = - @Entity + @Entity public class Order { @Id private Long id; public Long getId() { return id; } @@ -348,7 +348,7 @@ You can also override the access type of a single property w= hile keeping the other properties standard. = - @Entity + @Entity public class Order { @Id private Long id; public Long getId() { return id; } @@ -408,7 +408,7 @@ = - + @Entity public class Flight implements Serializable { ... @@ -448,7 +448,7 @@ = - @Column( + @Column( name=3D"columnName"; boolean unique() default false; boolean nullable() default true; @@ -528,7 +528,7 @@ @Embedded and @AttributeOverride annotation in the associated property: = - @Entity + @Entity public class Person implements Serializable { = // Persistent component using defaults @@ -543,13 +543,13 @@ ... } = - @Embeddable + @Embeddable public class Address implements Serializable { String city; Country nationality; //no overriding here } = - @Embeddable + @Embeddable public class Country implements Serializable { private String iso2; @Column(name=3D"countryName") private String name; @@ -582,14 +582,14 @@ columns of embedded objects of embedded objects is through dotted expressions. = - @Embedded + @Embedded @AttributeOverrides( { @AttributeOverride(name=3D"city", column =3D @Column(name=3D"f= ld_city") ), - @AttributeOverride(name=3D"nationality= .iso2", column =3D @Column(name=3D"nat_Iso2") ), - @AttributeOverride(name=3D"nationality= .name", column =3D @Column(name=3D"nat_CountryName") ) + @AttributeOverride(name=3D"nationality.iso2", column =3D @Colu= mn(name=3D"nat_Iso2") ), + @AttributeOverride(name=3D"nationality.name", column =3D @Colu= mn(name=3D"nat_CountryName") ) //nationality columns in homeAddress are overridden } ) - Address homeAddress;Hibernate Annotations supports + Address homeAddress;Hibernate Annotations suppo= rts something that is not explicitly supported by the JPA specificatio= n. You can annotate a embedded object with the @MappedSuperclass annotation to make the superc= lass @@ -691,12 +691,12 @@ The following example shows a sequence generator using the SEQ_STORE configuration (see below) = - @Id @GeneratedValue(strategy=3DGenerationType.SEQU= ENCE, generator=3D"SEQ_STORE") + @Id @GeneratedValu= e(strategy=3DGenerationType.SEQUENCE, generator=3D"SEQ_STORE") public Integer getId() { ... } = The next example uses the identity generator: = - @Id @GeneratedValue(strategy=3DGenerationType.IDEN= TITY) + @Id @GeneratedValu= e(strategy=3DGenerationType.IDENTITY) public Long getId() { ... } = The AUTO generator is the preferred type = for @@ -711,7 +711,7 @@ Application level generators are defined at XML level (see ): = - <table-generator name=3D"EMP_GEN" + <table-generato= r name=3D"EMP_GEN" table=3D"GENERATOR_TABLE" pk-column-name=3D"key" value-column-name=3D"hi" @@ -782,7 +782,7 @@ The next example shows the definition of a sequence generato= r in a class scope: = - @Entity + @Entity @javax.persistence.SequenceGenerator( name=3D"SEQ_STORE", sequenceName=3D"my_sequence" @@ -805,9 +805,9 @@ foreign generator but the JPA mapping reads better and is encouraged. = - @Entity + @Entity class MedicalHistory implements Serializable { - @Id @OneToOne + @Id @OneToOne @JoinColumn(name =3D "person_id") Person patient; } @@ -819,11 +819,11 @@ = Or alternatively = - @Entity + @Entity class MedicalHistory implements Serializable { @Id Integer id; = - @MapsId @OneToOne + @MapsId @OneToOne @JoinColumn(name =3D "patient_id") Person patient; } @@ -891,11 +891,11 @@ Here is a simple example of @EmbeddedId. = - @Entity = + @Entity class User { - @EmbeddedId = + @EmbeddedId @AttributeOverride(name=3D"firstName", column=3D@Column(name=3D"fld_firs= tname") - UserId id; + UserId id; = Integer age; } @@ -913,22 +913,22 @@ An embedded id can itself contains the primary key of an associated entity. = - @Entity + @Entity class Customer { @EmbeddedId CustomerId id; boolean preferredCustomer; = - @MapsId("userId") = + @MapsId("userId") @JoinColumns({ @JoinColumn(name=3D"userfirstname_fk", referencedColumnName=3D"firstNa= me"), @JoinColumn(name=3D"userlastname_fk", referencedColumnName=3D"lastName= ") }) - @OneToOne User user; + @OneToOne User user; } = @Embeddable class CustomerId implements Serializable { - UserId userId; + UserId userId; String customerNumber; } = @@ -969,7 +969,7 @@ association directly in the embedded id component (instead of ha= ving to use the @MapsId annotation). = - @Entity + @Entity class Customer { @EmbeddedId CustomerId id; boolean preferredCustomer; @@ -977,12 +977,12 @@ = @Embeddable class CustomerId implements Serializable { - @OneToOne + @OneToOne @JoinColumns({ @JoinColumn(name=3D"userfirstname_fk", referencedColumnName=3D"firstNa= me"), @JoinColumn(name=3D"userlastname_fk", referencedColumnName=3D"lastName= ") }) = - User user; + User user; String customerNumber; } = @@ -1007,16 +1007,16 @@ approach is only supported by Hibernate but does not require an extra embeddable component. = - @Entity -class Customer implements Serializable { - @Id @OneToOne + @Entity +class Customer implements Serializable { + @Id @OneToOne @JoinColumns({ @JoinColumn(name=3D"userfirstname_fk", referencedColumnName=3D"firstNa= me"), @JoinColumn(name=3D"userlastname_fk", referencedColumnName=3D"lastName= ") }) - User user; + User user; = - @Id String customerNumber; + @Id String customerNumber; = boolean preferredCustomer; } @@ -1055,22 +1055,22 @@ and Hibernate supports it. = - @Entity + @Entity class Customer { - @Id @OneToOne + @Id @OneToOne @JoinColumns({ @JoinColumn(name=3D"userfirstname_fk", referencedColumnName=3D"firstNa= me"), @JoinColumn(name=3D"userlastname_fk", referencedColumnName=3D"lastName= ") }) = - User user; + User user; = - @Id String customerNumber; + @Id String customerNumber; = boolean preferredCustomer; } = class CustomerId implements Serializable { - UserId user; + UserId user; String customerNumber; } = @@ -1095,22 +1095,22 @@ vanilla associated property in the @IdClass. = - @Entity + @Entity class Customer { - @Id @OneToOne + @Id @OneToOne @JoinColumns({ @JoinColumn(name=3D"userfirstname_fk", referencedColumnName=3D"firstNa= me"), @JoinColumn(name=3D"userlastname_fk", referencedColumnName=3D"lastName= ") }) = - User user; + User user; = - @Id String customerNumber; + @Id String customerNumber; = boolean preferredCustomer; } = class CustomerId implements Serializable { - @OneToOne User user; + @OneToOne User user; String customerNumber; } = @@ -1141,7 +1141,7 @@ this feature. = - @Entity = + @Entity public class CustomerInventory implements Serializable { @Id @TableGenerator(name =3D "inventory", @@ -1150,7 +1150,7 @@ valueColumnName =3D "S_NEXTNUM", pkColumnValue =3D "inventory", allocationSize =3D 1000) - @GeneratedValue(strategy =3D GenerationType.TABL= E, generator =3D "inventory") + @GeneratedValue(strategy =3D GenerationType.TABLE, generator =3D "invent= ory") Integer id; = = @@ -1210,7 +1210,7 @@ UNION queries. It is commonly used for the top level of = an inheritance hierarchy: = - @Entity + @Entity @Inheritance(strategy =3D InheritanceType.TABLE_PER_CLASS) public class Flight implements Serializable { ... } = @@ -1229,7 +1229,7 @@ same table, instances are distinguished by a special discriminator column: = - @Entity + @Entity @Inheritance(strategy=3DInheritanceType.SINGLE_TABLE) @DiscriminatorColumn( name=3D"planetype", @@ -1269,7 +1269,7 @@ @PrimaryKeyJoinColumns annotations define the primary key(s) of the joined subclass table: = - @Entity + @Entity @Inheritance(strategy=3DInheritanceType.JOINED) public class Boat implements Serializable { ... } = @@ -1296,7 +1296,7 @@ mapped entity (ie no specific table for this entity). For that pur= pose you can map them as @MappedSuperclass. = - @MappedSuperclass + @MappedSuperclass public class BaseEntity { @Basic @Temporal(TemporalType.TIMESTAMP) @@ -1351,7 +1351,7 @@ root entity level using the @AttributeOverride annotation. = - @MappedSuperclass + @MappedSuperclass public class FlyingObject implements Serializable { = public int getAltitude() { @@ -1412,7 +1412,7 @@ First, we map a real one-to-one association using shared pri= mary keys: = - @Entity + @Entity public class Body { @Id public Long getId() { return id; } @@ -1425,7 +1425,7 @@ ... } = - @Entity + @Entity public class Heart { @Id public Long getId() { ...} @@ -1438,17 +1438,17 @@ In the following example, the associated entities are linked through an explicit foreign key column: = - @Entity + @Entity public class Customer implements Serializable { @OneToOne(cascade =3D CascadeType.ALL) - @JoinColumn(name=3D"passport_fk") + @JoinColumn(name=3D"passport_fk") public Passport getPassport() { ... } = @Entity public class Passport implements Serializable { - @OneToOne(mappedBy =3D "passport") + @OneToOne(mappedBy =3D "passport") public Customer getOwner() { ... } @@ -1492,12 +1492,12 @@ The third possibility (using an association table) is quite exotic. = - @Entity + @Entity public class Customer implements Serializable { @OneToOne(cascade =3D CascadeType.ALL) - @JoinTable(name =3D "CustomerPassports", + @JoinTable(name =3D "CustomerPassports", joinColumns =3D @JoinColumn(name=3D"customer_fk"), - inverseJoinColumns =3D @JoinColumn(name=3D"passport_fk") + inverseJoinColumns =3D @JoinColumn(name=3D"passport_fk") ) public Passport getPassport() { ... @@ -1505,7 +1505,7 @@ = @Entity public class Passport implements Serializable { - @OneToOne(mappedBy =3D "passport") + @OneToOne(mappedBy =3D "passport") public Customer getOwner() { ... } @@ -1530,9 +1530,9 @@ Many-to-one associations are declared at the property level = with the annotation @ManyToOne: = - @Entity() + @Entity() public class Flight implements Serializable { - @ManyToOne( cascade =3D {CascadeTyp= e.PERSIST, CascadeType.MERGE} ) + @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} ) @JoinColumn(name=3D"COMP_ID") public Company getCompany() { return company; @@ -1555,10 +1555,9 @@ almost all cases. However this is useful when you want to use interfaces as the return type instead of the regular entity. = - @Entity + @Entity public class Flight implements Serializable { - @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, targetEntity=3DCompanyImpl.class ) + @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, targ= etEntity=3DCompanyImpl.class ) @JoinColumn(name=3D"COMP_ID") public Company getCompany() { return company; @@ -1578,13 +1577,13 @@ referencing the target entity table (through @JoinTable.inverseJoinColumns). = - @Entity + @Entity public class Flight implements Serializable { @ManyToOne( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE} ) - @JoinTable(name=3D"Flight_Company", + @JoinTable(name=3D"Flight_Company", joinColumns =3D @JoinColumn(name=3D"FLIGHT_ID"), inverseJoinColumns =3D @JoinColumn(name=3D"COMP_ID") - ) + ) public Company getCompany() { return company; } @@ -1620,7 +1619,7 @@ association is annotated by @OneToMany(mappedBy=3D...) = - @Entity + @Entity public class Troop { @OneToMany(mappedBy=3D"troop") public Set<Soldier> getSoldiers() { @@ -1648,7 +1647,7 @@ false. This solution is not optimized and will produce some additional UPDATE statements. = - @Entity + @Entity public class Troop { @OneToMany @JoinColumn(name=3D"troop_fk") //we need to duplicate the physical inf= ormation @@ -1675,7 +1674,7 @@ association is described through a @JoinColumn = - @Entity + @Entity public class Customer implements Serializable { @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFetchType.EAGER) @JoinColumn(name=3D"CUST_ID") @@ -1700,7 +1699,7 @@ preferred. This association is described through an @JoinTable. = - @Entity + @Entity public class Trainer { @OneToMany @JoinTable( @@ -1741,7 +1740,7 @@ added to the foreign key referencing the other side table to reflect the one to many. = - @Entity + @Entity public class Trainer { @OneToMany public Set<Tiger> getTrainedTigers() { @@ -1777,7 +1776,7 @@ the inverse end (ie. it will be ignored when updating the relationship values in the association table): = - @Entity + @Entity public class Employer implements Serializable { @ManyToMany( targetEntity=3Dorg.hibernate.test.metadata.manytomany.Employee.cla= ss, @@ -1794,7 +1793,7 @@ ... } = - @Entity + @Entity public class Employee implements Serializable { @ManyToMany( cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}, @@ -1836,7 +1835,7 @@ and the other side primary key column(s). These are the same r= ules used for a unidirectional one to many relationship. = - + @Entity public class Store { @ManyToMany(cascade =3D CascadeType.PERSIST) @@ -1868,7 +1867,7 @@ the other side primary key column(s). These are the same rules used for a unidirectional one to many relationship. = - @Entity + @Entity public class Store { @ManyToMany(cascade =3D {CascadeType.PERSIST, CascadeType.MERGE}) public Set<Customer> getCustomers() { @@ -1900,7 +1899,7 @@ objects. Use the @ElementCollection in th= is case. = - @Entity + @Entity public class User { [...] public String getLastname() { ...} @@ -1928,7 +1927,7 @@ embeddable object in the collection table, use the @AttributeOverride annotation. = - @Entity + @Entity public class User { [...] public String getLastname() { ...} @@ -1957,7 +1956,7 @@ key. prefix to override properties of the embeddable object used in the map key. = - @Entity + @Entity public class User { @ElementCollection @AttributeOverrides({ @@ -2000,14 +1999,14 @@ collection will be ordered by the primary key of the target entity. = - @Entity + @Entity public class Customer { @Id @GeneratedValue public Integer getId() { return id; } public void setId(Integer id) { this.id =3D id; } private Integer id; = @OneToMany(mappedBy=3D"customer") - @OrderBy("number") + @OrderBy("number") public List<Order> getOrders() { return orders; } public void setOrders(List<Order> orders) { this.orders =3D order= s; } private List<Order> orders; @@ -2048,14 +2047,14 @@ ORDER (in the following example, it would be orders_ORDER). = - @Entity + @Entity public class Customer { @Id @GeneratedValue public Integer getId() { return id; } public void setId(Integer id) { this.id =3D id; } private Integer id; = @OneToMany(mappedBy=3D"customer") - @OrderColumn(name"orders_index") + @OrderColumn(name"orders_index") public List<Order> getOrders() { return orders; } public void setOrders(List<Order> orders) { this.orders =3D order= s; } private List<Order> orders; @@ -2113,14 +2112,14 @@ other words, if you change the property value, the key will not change automatically in your Java model. = - @Entity + @Entity public class Customer { @Id @GeneratedValue public Integer getId() { return id; } public void setId(Integer id) { this.id =3D id; } private Integer id; = @OneToMany(mappedBy=3D"customer") - @MapKey(name"number") + @MapKey(name"number") public Map<String,Order> getOrders() { return orders; } public void setOrders(Map<String,Order> order) { this.orders =3D = orders; } private Map<String,Order> orders; @@ -2188,14 +2187,14 @@ should wonder why at this day and age you don't use generics). = - @Entity + @Entity public class Customer { @Id @GeneratedValue public Integer getId() { return id; } public void setId(Integer id) { this.id =3D id; } private Integer id; = @OneToMany @JoinTable(name=3D"Cust_Order") - @MapKeyColumn(name"orders_number") + @MapKeyColumn(name"orders_number") public Map<String,Order> getOrders() { return orders; } public void setOrders(Map<String,Order> orders) { this.orders =3D= orders; } private Map<String,Order> orders; @@ -2376,7 +2375,7 @@ to true. In a way, it means that the associated entity's lifecycle= is bound to the owning entity just like an embeddable object is. = - @Entity class Customer { + @Entity class Cust= omer { @OneToMany(orphanRemoval=3Dtrue) public Set<Order> getOrders() { = return orders; } public void setOrders(Set<Order> orders) { this.orders =3D orders= ; } private Set<Order> orders; @@ -2429,7 +2428,7 @@ You can also use @IdClass. These are more detaile= d in . = - @Entity + @Entity public class RegionalArticle implements Serializable { = @Id @@ -2441,7 +2440,7 @@ = or alternatively = - @Entity + @Entity public class RegionalArticle implements Serializable { = @EmbeddedId @@ -2459,7 +2458,7 @@ explicitly. Otherwise, Hibernate will suppose that you use the same order of columns as in the primary key declaration. = - @Entity + @Entity public class Parent implements Serializable { @Id public ParentPk id; @@ -2475,7 +2474,7 @@ ... } = - @Entity + @Entity public class Child implements Serializable { @Id @GeneratedValue public Integer id; @@ -2489,7 +2488,7 @@ public Parent parent; //unidirectional } = - @Embeddable + @Embeddable public class ParentPk implements Serializable { String firstName; String lastName; @@ -2510,14 +2509,14 @@ parameter of @Column or @JoinColumn. = - @Entity + @Entity @Table(name=3D"MainCat") -@SecondaryTables({ +(a)SecondaryTables({ @SecondaryTable(name=3D"Cat1", pkJoinColumns=3D{ @PrimaryKeyJoinColumn(name=3D"cat_id", referencedColumnName=3D"id") ), @SecondaryTable(name=3D"Cat2", uniqueConstraints=3D{@UniqueConstraint(= columnNames=3D{"storyPart2"})}) -}) +}) public class Cat implements Serializable { = private Integer id; @@ -2534,12 +2533,12 @@ return name; } = - @Column(table=3D"Cat1") + @Column(table=3D"Cat1") public String getStoryPart1() { return storyPart1; } = - @Column(table=3D"Cat2") + @Column(table=3D"Cat2") public String getStoryPart2() { return storyPart2; } @@ -2624,7 +2623,7 @@ that. = - @Entity @Cacheable + @Entity @Cacheable @Cache(usage =3D CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class Forest { ... } = @@ -2633,7 +2632,7 @@ @Cache annotation on the collection property. = - @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFetchT= ype.EAGER) + @OneToMany(cascade= =3DCascadeType.ALL, fetch=3DFetchType.EAGER) @JoinColumn(name=3D"CUST_ID") @Cache(usage =3D CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public SortedSet<Ticket> getTickets() { @@ -2652,7 +2651,7 @@ = - @Cache( + @Cache( CacheConcurrencyStrategy usage(); String region() default ""; String include() default "all"; @@ -2709,7 +2708,7 @@ manager factory scope. A named query is defined by its name and the actual query string. = - <entity-mappings> + <entity-mappings&= gt; <named-query name=3D"plane.getAll"> <query>select p from Plane p</query> </named-query> @@ -2739,7 +2738,6 @@ = The available Hibernate hints are = - = Query hints @@ -2839,10 +2837,10 @@ definitions are optional provided that they map to the same column n= ame as the one declared on the class property. = - @NamedNativeQuery(name=3D"night&area", que= ry=3D"select night.id nid, night.night_duration, " + @NamedNativeQuery(na= me=3D"night&area", query=3D"select night.id nid, night.night_duration, " + " night.night_date, area.id aid, night.area_id, area.name " + "from Night night, Area area where night.area_id =3D area.id", = - resultSetMapping=3D"joinMapping"= ) + resultSetMapping=3D"joinMapping") @SqlResultSetMapping(name=3D"joinMapping", entities=3D{ @EntityResult(entityClass=3DNight.class, fields =3D { @FieldResult(name=3D"id", column=3D"nid"), @@ -2856,7 +2854,7 @@ @FieldResult(name=3D"name", column=3D"name") }) } -) +) = In the above example, the night&area na= med query use the joinMapping result set mapping. This @@ -2865,12 +2863,12 @@ column name, actually the column name retrieved by the query. Let's = now see an implicit declaration of the property / column. = - @Entity -@SqlResultSetMapping(name=3D"implicit", = + @Entity +(a)SqlResultSetMapping(name=3D"implicit", entities=3D@EntityResult(entityClass=3DSpaceShip.clas= s)) @NamedNativeQuery(name=3D"implicitSample", = query=3D"select * from SpaceShip", = - resultSetMapping=3D"implicit") + resultSetMapping=3D"implicit") public class SpaceShip { private String name; private String model; @@ -2913,15 +2911,15 @@ property name for the relationship, followed by a dot ("."), followe= d by the name or the field or property of the primary key. = - @Entity + @Entity @SqlResultSetMapping(name=3D"compositekey", entities=3D@EntityResult(entityClass=3DSpaceShip.class, fields =3D { @FieldResult(name=3D"name", column =3D "name"), @FieldResult(name=3D"model", column =3D "model"), @FieldResult(name=3D"speed", column =3D "speed"), - @FieldResult(name=3D"captain.f= irstname", column =3D "firstn"), - @FieldResult(name=3D"captain.lastname", column =3D "la= stn"), + @FieldResult(name=3D"captain.firstname", column =3D "f= irstn"), + @FieldResult(name=3D"captain.lastname", column =3D "la= stn"), @FieldResult(name=3D"dimensions.length", column =3D "l= ength"), @FieldResult(name=3D"dimensions.width", column =3D "wi= dth") }), @@ -3016,8 +3014,8 @@ mapping, you can use the resultClass attribute instead of resultSetMapping: = - @NamedNativeQuery(name=3D"im= plicitSample", query=3D"select * from SpaceShip", = - resultClass=3DSpaceShip.class) + @NamedNativeQuery(na= me=3D"implicitSample", query=3D"select * from SpaceShip", + resultClass=3DSpaceShip.class) public class SpaceShip { = In some of your native queries, you'll have to return scalar @@ -3027,8 +3025,8 @@ and scalar returns in the same native query (this is probably not th= at common though). = - @SqlResultSetMapping(name=3D= "scalar", columns=3D@ColumnResult(name=3D"dimension")) -(a)NamedNativeQuery(name=3D"scalar", query=3D"select length*width as dimen= sion from SpaceShip", resultSetMapping=3D"scalar") + @SqlResultSetMapping= (name=3D"scalar", columns=3D@ColumnResult(name=3D"dimension")) +(a)NamedNativeQuery(name=3D"scalar", query=3D"select length*width as dimen= sion from SpaceShip", resultSetMapping=3D"scalar") = An other query hint specific to native queries has been introduced: org.hibernate.callable which can be t= rue @@ -3189,7 +3187,7 @@ implements persistence via, for example, stored procedure calls, serialization to flat files or LDAP. = - @Entity + @Entity @BatchSize(size=3D5) @org.hibernate.annotations.Entity( selectBeforeUpdate =3D true, @@ -3199,7 +3197,7 @@ @Where(clause=3D"1=3D1") @org.hibernate.annotations.Table(name=3D"Forest", indexes =3D { @Index(nam= e=3D"idx", columnNames =3D { "name", "length" } ) } ) @Persister(impl=3DMyEntityPersister.class) -public class Forest { ... } @Entity +public class Forest { ... } @Entity @Inheritance( strategy=3DInheritanceType.JOINED ) @@ -3207,7 +3205,7 @@ = @Entity @OnDelete(action=3DOnDeleteAction.CASCADE) -public class Carrot extends Vegetable { ... } +public class Carrot extends Vegetable { ... } =
@@ -3224,7 +3222,7 @@ allows you to define an Hibernate specific id generator. = - @Id @GeneratedValue(generator=3D"system-uuid= ") + @Id @GeneratedValu= e(generator=3D"system-uuid") @GenericGenerator(name=3D"system-uuid", strategy =3D "uuid") public String getId() { = @@ -3235,7 +3233,7 @@ @Parameter(name=3D"sequence", value=3D"heybabyhey") } ) -public Integer getId() { +public Integer getId() { = strategy is the short name of an Hibernat= e3 generator strategy or the fully qualified class name of an @@ -3249,7 +3247,7 @@ annotations, making them application level generators (just like if they were in a JPA XML file). = - @GenericGenerators( + @GenericGenerators( { @GenericGenerator( name=3D"hibseq", @@ -3277,7 +3275,7 @@ composed of all the properties marked @NaturalId. = - @Entity + @Entity public class Citizen { @Id @GeneratedValue @@ -3319,7 +3317,7 @@ property into a column. This kind of property is read only (its va= lue is calculated by your formula fragment). = - @Formula("obj_length * obj_height * obj_width") + @Formula("obj_leng= th * obj_height * obj_width") public long getObjectVolume() = The SQL fragment can be as complex as you want and even incl= ude @@ -3355,7 +3353,7 @@ Place your annotations before the package declaration. = - @TypeDef( + @TypeDef( name =3D "phoneNumber", defaultForType =3D PhoneNumber.class, typeClass =3D PhoneNumberType.class @@ -3374,7 +3372,7 @@ parameters attribute to customize the TypeDef. = - //in org/hibernate/test/annotations/entity/package= -info.java + //in org/hibernate= /test/annotations/entity/package-info.java @TypeDefs( { @TypeDef( @@ -3399,7 +3397,7 @@ definitions. The @Columns has been introduced f= or that purpose. = - @Type(type=3D"org.hibernate.test.annotations.entit= y.MonetaryAmountUserType") + @Type(type=3D"org.= hibernate.test.annotations.entity.MonetaryAmountUserType") @Columns(columns =3D { @Column(name=3D"r_amount"), @Column(name=3D"r_currency") @@ -3423,7 +3421,7 @@ @Index annotation on a one column property, the columnNames attribute will then be ignored = - @Column(secondaryTable=3D"Cat1") + @Column(secondaryT= able=3D"Cat1") @Index(name=3D"story1index") public String getStoryPart1() { return storyPart1; @@ -3436,7 +3434,7 @@ When inside an embeddable object, you can define one of the properties as a pointer back to the owner element. = - @Entity + @Entity public class Person { @Embeddable public Address address; ... @@ -3459,7 +3457,7 @@ database. Hibernate can deal with such properties and triggers a subsequent select to read these properties. = - @Entity + @Entity public class Antenna { @Id public Integer id; @Generated(GenerationTime.ALWAYS) = @@ -3493,8 +3491,8 @@ targetEntity attribute available on associations. = - @Embedded - @Target(OwnerImpl.class) + @Embedded + @Target(OwnerImpl.class) public Owner getOwner() { return owner; } @@ -3525,8 +3523,8 @@ formula for discriminator resolution (no need to have a dedicated column). = - @Entity -@DiscriminatorFormula("case when forest_type is nu= ll then 0 else forest_type end") + @Entity +(a)DiscriminatorFormula("case when forest_type is null then 0 else forest_= type end") public class Forest { ... } = By default, when querying the top entities, Hibernate does not= put @@ -3540,7 +3538,7 @@ You can define the foreign key name generated by Hibernate for subclass tables in the JOINED inheritance strategy. = - @Entity + @Entity @Inheritance(strategy =3D InheritanceType.JOINED) public abstract class File { ... } = @@ -3566,7 +3564,7 @@ @ManyToOne, @OneToMany or @ManyToMany association. = - @Entity + @Entity public class Child { ... @ManyToOne @@ -3578,7 +3576,7 @@ Sometimes you want to delegate to your database the deletion of cascade when a given entity is deleted. = - @Entity + @Entity public class Child { ... @ManyToOne @@ -3594,11 +3592,11 @@ fairly unreadable name. You can override the constraint name by use @ForeignKey. = - @Entity + @Entity public class Child { ... @ManyToOne - @ForeignKey(name=3D"FK_PARENT") + @ForeignKey(name=3D"FK_PARENT") public Parent getParent() { ... } ... } @@ -3724,7 +3722,7 @@ @AnyDef and @AnyDefs annotations are used. = - @Any( metaColumn =3D @Column( name =3D "proper= ty_type" ), fetch=3DFetchType.EAGER ) + @Any( metaColu= mn =3D @Column( name =3D "property_type" ), fetch=3DFetchType.EAGER ) @AnyMetaDef( = idType =3D "integer", = metaType =3D "string", = @@ -3745,7 +3743,7 @@ reused. It is recommended to place it as a package metadata in this case. = - //on a package + //on a package @AnyMetaDef( name=3D"property" = idType =3D "integer", = metaType =3D "string", = @@ -3818,7 +3816,7 @@ SortedSet or a SortedMap interface. = - @OneToMany(cascade=3DCascadeType.ALL, fetch=3D= FetchType.EAGER) + @OneToMany(cas= cade=3DCascadeType.ALL, fetch=3DFetchType.EAGER) @JoinColumn(name=3D"CUST_ID") @Sort(type =3D SortType.COMPARATOR, comparator =3D TicketComparator.cl= ass) @Where(clause=3D"1=3D1") @@ -3837,11 +3835,11 @@ inverseName referencing to the other side constraint. = - @Entity + @Entity public class Woman { ... @ManyToMany(cascade =3D {CascadeType.ALL}) - @ForeignKey(name =3D "TO_WOMAN_FK", inverseNam= e =3D "TO_MAN_FK") + @ForeignKey(name =3D "TO_WOMAN_FK", inverseName =3D "TO_MAN_FK") public Set<Man> getMens() { return mens; } @@ -3863,7 +3861,7 @@ associated class explicitly maps the indexed value, the use of mappedBy is permitted: = - @Entity + @Entity public class Parent { @OneToMany(mappedBy=3D"parent") @OrderColumn(name=3D"order") @@ -3891,7 +3889,7 @@ the collection as mappedBy. Instead, we could= use the following mapping: = - @Entity + @Entity public class Parent { @OneToMany @OrderColumn(name=3D"order") @@ -3927,18 +3925,18 @@ generator strategy. The strategy can be identity, or any defined generator name of your application. = - @Entity + @Entity @TableGenerator(name=3D"ids_generator", table=3D"IDS") public class Passport { ... = @ManyToMany(cascade =3D CascadeType.ALL) @JoinTable(name=3D"PASSPORT_VISASTAMP") - @CollectionId( + @CollectionId( columns =3D @Column(name=3D"COLLECTION_ID"), = type=3D@Type(type=3D"long"), = generator =3D "ids_generator" - ) + ) private Collection<Stamp> visaStamp =3D new ArrayList(); ... } @@ -3957,7 +3955,7 @@ only in very special cases (eg. audit logs, user session data, etc). = - @ManyToAny( + @ManyToAny( metaColumn =3D @Column( name =3D "property_type" ) ) @AnyMetaDef( = idType =3D "integer", = @@ -4035,9 +4033,8 @@ PERSIST at flush time as per the specification). = - @OneToMany( cascade =3D {CascadeType.PERSIST, Cascad= eType.MERGE} ) -(a)Cascade(org.hibernate.annotations.CascadeType.REPLICATE) + @OneToMany( cascade = =3D {CascadeType.PERSIST, CascadeType.MERGE} ) +(a)Cascade(org.hibernate.annotations.CascadeType.REPLICATE) public Collection<Employer> getEmployers() = It is recommended to use @Cascade to @@ -4068,13 +4065,13 @@ entity load or the collection load. @Filter is us= ed and placed either on the entity or the collection element = - @Entity + @Entity @FilterDef(name=3D"minLength", parameters=3D@ParamDef( name=3D"minLength",= type=3D"integer" ) ) @Filters( { @Filter(name=3D"betweenLength", condition=3D":minLength <=3D length= and :maxLength >=3D length"), @Filter(name=3D"minLength", condition=3D":minLength <=3D length") } ) -public class Forest { ... } +public class Forest { ... } = When the collection use an association table as a relational representation, you might want to apply the filter condition to the @@ -4084,7 +4081,7 @@ association table, use the @FilterJoinTable annotation. = - @OneToMany + @OneToMany @JoinTable //filter on the target entity table @Filter(name=3D"betweenLength", condition=3D":minLength <=3D length= and :maxLength >=3D length") @@ -4162,13 +4159,13 @@ you can also override the SQL statement used to load or change the s= tate of entities. = - @Entity + @Entity @Table(name=3D"CHAOS") -@SQLInsert( sql=3D"INSERT INTO CHAOS(size, name, n= ickname, id) VALUES(?,upper(?),?,?)") +(a)SQLInsert( sql=3D"INSERT INTO CHAOS(size, name, nickname, id) VALUES(?,= upper(?),?,?)") @SQLUpdate( sql=3D"UPDATE CHAOS SET size =3D ?, name =3D upper(?), nicknam= e =3D ? WHERE id =3D ?") @SQLDelete( sql=3D"DELETE CHAOS WHERE id =3D ?") @SQLDeleteAll( sql=3D"DELETE CHAOS") -@Loader(namedQuery =3D "chaos") +(a)Loader(namedQuery =3D "chaos") @NamedNativeQuery(name=3D"chaos", query=3D"select id, size, name, lower( n= ickname ) as nickname from CHAOS where id=3D ?", resultClass =3D Chaos.clas= s) public class Chaos { @Id @@ -4217,10 +4214,10 @@ You can use the exact same set of annotations to override the collection related statements. = - @OneToMany + @OneToMany @JoinColumn(name=3D"chaos_fk") -@SQLInsert( sql=3D"UPDATE CASIMIR_PARTICULE SET ch= aos_fk =3D ? where id =3D ?") -(a)SQLDelete( sql=3D"UPDATE CASIMIR_PARTICULE SET chaos_fk =3D null where = id =3D ?") +(a)SQLInsert( sql=3D"UPDATE CASIMIR_PARTICULE SET chaos_fk =3D ? where id = =3D ?") +(a)SQLDelete( sql=3D"UPDATE CASIMIR_PARTICULE SET chaos_fk =3D null where = id =3D ?") private Set<CasimirParticle> particles =3D new HashSet<CasimirPar= ticle>(); = The parameters order is important and is defined by the order @@ -4237,14 +4234,14 @@ all) attributes sqlInsert, sqlUpdate, sqlDelete: = - @Entity + @Entity @SecondaryTables({ @SecondaryTable(name =3D "`Cat nbr1`"), @SecondaryTable(name =3D "Cat2"}) @org.hibernate.annotations.Tables( { @Table(appliesTo =3D "Cat", comment =3D "My cat table" ), @Table(appliesTo =3D "Cat2", foreignKey =3D @ForeignKey(name=3D"FK_CAT= 2_CAT"), fetch =3D FetchMode.SELECT, - sqlInsert=3D@SQLInsert(sql=3D"insert into = Cat2(storyPart2, id) values(upper(?), ?)") ) + sqlInsert=3D@SQLInsert(sql=3D"insert into Cat2(storyPart2, id) val= ues(upper(?), ?)") ) } ) public class Cat implements Serializable { = @@ -4277,8 +4274,8 @@ To define tuplixer in annotations, simply use the @Tuplizer annotation on the according element = - @Entity -@Tuplizer(impl =3D DynamicEntityTuplizer.class) + @Entity +(a)Tuplizer(impl =3D DynamicEntityTuplizer.class) public interface Cuisine { @Id @GeneratedValue @@ -4288,7 +4285,7 @@ public String getName(); public void setName(String name); = - @Tuplizer(impl =3D DynamicComponentTuplizer.cl= ass) + @Tuplizer(impl =3D DynamicComponentTuplizer.class) public Country getCountry(); public void setCountry(Country country); } @@ -4307,10 +4304,10 @@ fetch profile will be in affect for that session until it is explici= tly disabled. Lets look at an example: = - @Entity -@FetchProfile(name =3D "customer-with-orders", fet= chOverrides =3D { + @Entity +(a)FetchProfile(name =3D "customer-with-orders", fetchOverrides =3D { @FetchProfile.FetchOverride(entity =3D Customer.class, association =3D = "orders", mode =3D FetchMode.JOIN) -}) +}) public class Customer { @Id @GeneratedValue @@ -4325,12 +4322,13 @@ = // standard getter/setter ... -}In the normal case the orders association would be lazy +} + In the normal case the orders association would be lazy loaded by Hibernate, but in a usecase where it is more efficient to = load the customer and their orders together you could do something like this: = - Session session =3D ...; + Session session =3D = ...; session.enableFetchProfile( "customer-with-orders" ); // name matches @Fe= tchProfile name Customer customer =3D (Customer) session.get( Customer.class, customerId ); session.disableFetchProfile( "customer-with-orders" ); // or just close th= e session Modified: core/trunk/annotations/src/main/docbook/en/modules/setup.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/main/docbook/en/modules/setup.xml 2010-03-08= 17:56:55 UTC (rev 18933) +++ core/trunk/annotations/src/main/docbook/en/modules/setup.xml 2010-03-08= 18:24:20 UTC (rev 18934) @@ -46,7 +46,7 @@ Alternatively add the following dependency in your dependency manager (like Maven or Ivy). Here is an example = - <project ...> + <project ...> ... <dependencies> <dependency> @@ -97,7 +97,8 @@ hibernate-validator.jar and validation-api.jar in your classpath. Alternative= ly add the following dependency in your - pom.xml.<project> + pom.xml. + <project> ... <dependencies> <dependency> @@ -108,7 +109,7 @@ ... </dependencies> ... -</project> +</project> = If you wish to use Hibernate Search, download= it @@ -116,7 +117,7 @@ hibernate-search.jar and lucene-core-x.y.z.jar in your classpath. Alternatively add the following dependency in your - pom.xml.<project> + pom.xml.<project> ... <dependencies> <dependency> @@ -127,7 +128,7 @@ ... </dependencies> ... -</project> +</project> = We recommend you use the JPA 2 APIs to bootstrap Hibernate (see = the Hibernate EntityManager documentation for more information). If you use @@ -136,7 +137,8 @@ If you boot Hibernate yourself, make sure to use the AnnotationConfiguration class instead of the Configuration class. Here is an example using t= he - (legacy) HibernateUtil approach: package hello; + (legacy) HibernateUtil approach: + package hello; = import org.hibernate.*; import org.hibernate.cfg.*; @@ -146,12 +148,10 @@ public class HibernateUtil { = private static final SessionFactory sessionFactory; - static { try { - sessionFactory =3D new AnnotationConfi= guration() - configure().buildSessionFactory(); + .configure().buildSessionFactory(); } catch (Throwable ex) { // Log exception! throw new ExceptionInInitializerError(ex); @@ -163,7 +163,7 @@ return sessionFactory.openSession(); } } - + = Interesting here is the use of AnnotationConfiguration. The packages and annot= ated @@ -171,20 +171,20 @@ hibernate.cfg.xml). Here is the equivalent of the above declaration: = - <!DOCTYPE hibernate-configuration PUBLIC + <!DOCTYPE hibernate-c= onfiguration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> - <hibernate-configuration> <session-factory> - <mapping package=3D"test.animals"/> + <mapping package=3D"test.animals"/> <mapping class=3D"test.Flight"/> <mapping class=3D"test.Sky"/> <mapping class=3D"test.Person"/> - <mapping class=3D"test.animals.Dog"/> - <mapping resource=3D"test/animals/orm.xml"/= > + <mapping class=3D"test.animals.Dog"/> + + <mapping resource=3D"test/animals/orm.xml"/> </session-factory> -</hibernate-configuration> +</hibernate-configuration> = Note that you can mix the legacy hbm.xml use and the annotation approach. The resource element can be either an hbm file or an EJB3 XML @@ -194,13 +194,13 @@ Alternatively, you can define the annotated classes and packages using the programmatic API = - sessionFactory =3D new Annotat= ionConfiguration() + sessionFactory =3D new= AnnotationConfiguration() .addPackage("test.animals") //the fully qualified pack= age name .addAnnotatedClass(Flight.class) .addAnnotatedClass(Sky.class) .addAnnotatedClass(Person.class) - .addAnnotatedClass(Dog.class) - .addResource("test/animals/orm= .xml") + .addAnnotatedClass(Dog.class) + .addResource("test/animals/orm.xml") .configure() .buildSessionFactory(); = Modified: core/trunk/annotations/src/main/docbook/en/modules/xml-overriding= .xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/annotations/src/main/docbook/en/modules/xml-overriding.xml 2= 010-03-08 17:56:55 UTC (rev 18933) +++ core/trunk/annotations/src/main/docbook/en/modules/xml-overriding.xml 2= 010-03-08 18:24:20 UTC (rev 18934) @@ -53,7 +53,7 @@ You can define global level metadata available for all XML fil= es. You must not define these metadata more than once per deployment. = - <?xml version=3D"1.0" encoding=3D"UTF-8"?> + <?xml version=3D"1.= 0" encoding=3D"UTF-8"?> = <entity-mappings = xmlns=3D"http://java.sun.com/xml/ns/persistence/orm" @@ -347,7 +347,7 @@ mapped-superclass/attributes or embeddable/attributes. = - <attributes> + <attributes> <id name=3D"id"> <column name=3D"fld_id"/> <generated-value generator=3D"generator" strategy=3D"SEQUEN= CE"/> @@ -388,7 +388,7 @@ mapped-superclass/attributes or embeddable/attributes. = - <attributes> + <attributes> <one-to-many name=3D"players" fetch=3D"EAGER"> <map-key name=3D"name"/> <join-column name=3D"driver"/> --===============3687617456052002360==--