From 9be297241de91d3d991cbfeb6a42973b6bb9eb23 Mon Sep 17 00:00:00 2001 From: Emmanuel Bernard Date: Tue, 9 Mar 2010 14:49:39 +0000 Subject: [PATCH] HHH-4933 move to jHighlighting git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18940 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../docbook/en/modules/additionalmodules.xml | 4 +- .../src/main/docbook/en/modules/entity.xml | 237 +++++++++--------- .../src/main/docbook/en/modules/setup.xml | 22 +- .../docbook/en/modules/xml-overriding.xml | 16 +- 4 files changed, 143 insertions(+), 136 deletions(-) diff --git a/annotations/src/main/docbook/en/modules/additionalmodules.xml b/annotations/src/main/docbook/en/modules/additionalmodules.xml index 474c9ff5ec..91eb274ddf 100644 --- a/annotations/src/main/docbook/en/modules/additionalmodules.xml +++ b/annotations/src/main/docbook/en/modules/additionalmodules.xml @@ -122,7 +122,7 @@ ddl together by setting the property to callback, dll - <persistence ...> + <persistence ...> <persistence-unit ...> ... <properties> @@ -171,7 +171,7 @@ Using custom groups for validation - <persistence ...> + <persistence ...> <persistence-unit ...> ... <properties> diff --git a/annotations/src/main/docbook/en/modules/entity.xml b/annotations/src/main/docbook/en/modules/entity.xml index d9e646ddd3..3cd80e807a 100644 --- a/annotations/src/main/docbook/en/modules/entity.xml +++ b/annotations/src/main/docbook/en/modules/entity.xml @@ -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 @@ public class Flight implements Serializable { mapping. If no @Table is defined the default values are used: the unqualified class name of the entity. - @Entity + @Entity @Table(name="tbl_sky") public class Sky implements Serializable { ... @@ -117,7 +117,7 @@ public class Sky implements Serializable { @Column.unique approach (refer to @Column for more information). - @Table(name="tbl_sky", + @Table(name="tbl_sky", uniqueConstraints = {@UniqueConstraint(columnNames={"month", "day"})} ) @@ -142,7 +142,7 @@ public class Sky implements Serializable { 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 @@ public class Flight implements Serializable { annotation allows you to declare the fetching strategy for a property: - public transient int counter; //transient property + public transient int counter; //transient property private String firstname; //persistent property @@ -252,7 +252,7 @@ Starred getNote() { ... } //enum persisted as String in databasebyte[] and serializable type will be persisted in a Blob. - + @Lob public String getFullText() { return fullText; @@ -313,7 +313,7 @@ public byte[] getFullCode() { 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 @@ public class Address { You can also override the access type of a single property while keeping the other properties standard. - @Entity + @Entity public class Order { @Id private Long id; public Long getId() { return id; } @@ -408,7 +408,7 @@ public class Order { - + @Entity public class Flight implements Serializable { ... @@ -448,7 +448,7 @@ public String getName() { ... } - @Column( + @Column( name="columnName"; boolean unique() default false; boolean nullable() default true; @@ -528,7 +528,7 @@ public String getName() { ... } @Embedded and @AttributeOverride annotation in the associated property: - @Entity + @Entity public class Person implements Serializable { // Persistent component using defaults @@ -543,13 +543,13 @@ public class Person implements Serializable { ... } - @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="countryName") private String name; @@ -582,19 +582,20 @@ public class Country implements Serializable { columns of embedded objects of embedded objects is through dotted expressions. - @Embedded + @Embedded @AttributeOverrides( { @AttributeOverride(name="city", column = @Column(name="fld_city") ), @AttributeOverride(name="nationality.iso2", column = @Column(name="nat_Iso2") ), @AttributeOverride(name="nationality.name", column = @Column(name="nat_CountryName") ) //nationality columns in homeAddress are overridden } ) - Address homeAddress;Hibernate Annotations supports - something that is not explicitly supported by the JPA specification. - You can annotate a embedded object with the - @MappedSuperclass annotation to make the superclass - properties persistent (see @MappedSuperclass for - more informations). + Address homeAddress; + + Hibernate Annotations supports something that is not explicitly + supported by the JPA specification. You can annotate a embedded object + with the @MappedSuperclass annotation to make the + superclass properties persistent (see + @MappedSuperclass for more informations). You can also use association annotations in an embeddable object (ie @OneToOne, @ManyToOne, @@ -691,12 +692,12 @@ public class Country implements Serializable { The following example shows a sequence generator using the SEQ_STORE configuration (see below) - @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_STORE") + @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_STORE") public Integer getId() { ... } The next example uses the identity generator: - @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) public Long getId() { ... } The AUTO generator is the preferred type for @@ -711,7 +712,7 @@ public Long getId() { ... } Application level generators are defined at XML level (see ): - <table-generator name="EMP_GEN" + <table-generator name="EMP_GEN" table="GENERATOR_TABLE" pk-column-name="key" value-column-name="hi" @@ -782,7 +783,7 @@ public Long getId() { ... } The next example shows the definition of a sequence generator in a class scope: - @Entity + @Entity @javax.persistence.SequenceGenerator( name="SEQ_STORE", sequenceName="my_sequence" @@ -805,7 +806,7 @@ public class Store implements Serializable { foreign generator but the JPA mapping reads better and is encouraged. - @Entity + @Entity class MedicalHistory implements Serializable { @Id @OneToOne @JoinColumn(name = "person_id") @@ -819,7 +820,7 @@ public class Person implements Serializable { Or alternatively - @Entity + @Entity class MedicalHistory implements Serializable { @Id Integer id; @@ -891,7 +892,7 @@ class Person { Here is a simple example of @EmbeddedId. - @Entity + @Entity class User { @EmbeddedId @AttributeOverride(name="firstName", column=@Column(name="fld_firstname") @@ -913,7 +914,7 @@ class UserId implements Serializable { An embedded id can itself contains the primary key of an associated entity. - @Entity + @Entity class Customer { @EmbeddedId CustomerId id; boolean preferredCustomer; @@ -969,7 +970,7 @@ class UserId implements Serializable { association directly in the embedded id component (instead of having to use the @MapsId annotation). - @Entity + @Entity class Customer { @EmbeddedId CustomerId id; boolean preferredCustomer; @@ -1007,7 +1008,7 @@ class UserId implements Serializable { approach is only supported by Hibernate but does not require an extra embeddable component. - @Entity + @Entity class Customer implements Serializable { @Id @OneToOne @JoinColumns({ @@ -1055,7 +1056,7 @@ class UserId implements Serializable { and Hibernate supports it. - @Entity + @Entity class Customer { @Id @OneToOne @JoinColumns({ @@ -1095,7 +1096,7 @@ class UserId implements Serializable { vanilla associated property in the @IdClass. - @Entity + @Entity class Customer { @Id @OneToOne @JoinColumns({ @@ -1141,7 +1142,7 @@ class UserId implements Serializable { this feature. - @Entity + @Entity public class CustomerInventory implements Serializable { @Id @TableGenerator(name = "inventory", @@ -1210,7 +1211,7 @@ public class Customer implements Serializable { UNION queries. It is commonly used for the top level of an inheritance hierarchy: - @Entity + @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class Flight implements Serializable { ... } @@ -1229,7 +1230,7 @@ public class Flight implements Serializable { ... } same table, instances are distinguished by a special discriminator column: - @Entity + @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn( name="planetype", @@ -1269,7 +1270,7 @@ public class A320 extends Plane { ... } @PrimaryKeyJoinColumns annotations define the primary key(s) of the joined subclass table: - @Entity + @Entity @Inheritance(strategy=InheritanceType.JOINED) public class Boat implements Serializable { ... } @@ -1296,7 +1297,7 @@ public class AmericaCupClass extends Boat { ... } mapped entity (ie no specific table for this entity). For that purpose you can map them as @MappedSuperclass. - @MappedSuperclass + @MappedSuperclass public class BaseEntity { @Basic @Temporal(TemporalType.TIMESTAMP) @@ -1351,7 +1352,7 @@ public class BaseEntity { root entity level using the @AttributeOverride annotation. - @MappedSuperclass + @MappedSuperclass public class FlyingObject implements Serializable { public int getAltitude() { @@ -1412,7 +1413,7 @@ public class Plane extends FlyingObject { First, we map a real one-to-one association using shared primary keys: - @Entity + @Entity public class Body { @Id public Long getId() { return id; } @@ -1425,7 +1426,7 @@ public class Body { ... } - @Entity + @Entity public class Heart { @Id public Long getId() { ...} @@ -1438,7 +1439,7 @@ public class Heart { In the following example, the associated entities are linked through an explicit foreign key column: - @Entity + @Entity public class Customer implements Serializable { @OneToOne(cascade = CascadeType.ALL) @JoinColumn(name="passport_fk") @@ -1492,7 +1493,7 @@ public class Passport implements Serializable { The third possibility (using an association table) is quite exotic. - @Entity + @Entity public class Customer implements Serializable { @OneToOne(cascade = CascadeType.ALL) @JoinTable(name = "CustomerPassports", @@ -1530,7 +1531,7 @@ public class Passport implements Serializable { Many-to-one associations are declared at the property level with the annotation @ManyToOne: - @Entity() + @Entity() public class Flight implements Serializable { @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} ) @JoinColumn(name="COMP_ID") @@ -1555,7 +1556,7 @@ public class Flight implements Serializable { 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 = {CascadeType.PERSIST, CascadeType.MERGE}, targetEntity=CompanyImpl.class ) @JoinColumn(name="COMP_ID") @@ -1577,7 +1578,7 @@ public interface Company { referencing the target entity table (through @JoinTable.inverseJoinColumns). - @Entity + @Entity public class Flight implements Serializable { @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} ) @JoinTable(name="Flight_Company", @@ -1619,7 +1620,7 @@ public class Flight implements Serializable { association is annotated by @OneToMany(mappedBy=...) - @Entity + @Entity public class Troop { @OneToMany(mappedBy="troop") public Set<Soldier> getSoldiers() { @@ -1647,7 +1648,7 @@ public class Soldier { false. This solution is not optimized and will produce some additional UPDATE statements. - @Entity + @Entity public class Troop { @OneToMany @JoinColumn(name="troop_fk") //we need to duplicate the physical information @@ -1674,7 +1675,7 @@ public class Soldier { association is described through a @JoinColumn - @Entity + @Entity public class Customer implements Serializable { @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER) @JoinColumn(name="CUST_ID") @@ -1699,7 +1700,7 @@ public class Ticket implements Serializable { preferred. This association is described through an @JoinTable. - @Entity + @Entity public class Trainer { @OneToMany @JoinTable( @@ -1740,7 +1741,7 @@ public class Monkey { 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() { @@ -1776,7 +1777,7 @@ public class Tiger { 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=org.hibernate.test.metadata.manytomany.Employee.class, @@ -1793,7 +1794,7 @@ public class Employer implements Serializable { ... } - @Entity + @Entity public class Employee implements Serializable { @ManyToMany( cascade = {CascadeType.PERSIST, CascadeType.MERGE}, @@ -1835,7 +1836,7 @@ public class Employee implements Serializable { and the other side primary key column(s). These are the same rules used for a unidirectional one to many relationship. - + @Entity public class Store { @ManyToMany(cascade = CascadeType.PERSIST) @@ -1867,7 +1868,7 @@ public class City { 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 = {CascadeType.PERSIST, CascadeType.MERGE}) public Set<Customer> getCustomers() { @@ -1899,7 +1900,7 @@ public class Customer { objects. Use the @ElementCollection in this case. - @Entity + @Entity public class User { [...] public String getLastname() { ...} @@ -1927,7 +1928,7 @@ public class User { embeddable object in the collection table, use the @AttributeOverride annotation. - @Entity + @Entity public class User { [...] public String getLastname() { ...} @@ -1956,7 +1957,7 @@ public class Address { key. prefix to override properties of the embeddable object used in the map key. - @Entity + @Entity public class User { @ElementCollection @AttributeOverrides({ @@ -1999,7 +2000,7 @@ public class User { 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 = id; } @@ -2047,7 +2048,7 @@ public class Order { 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 = id; } @@ -2112,7 +2113,7 @@ public class Order { 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 = id; } @@ -2187,7 +2188,7 @@ public class Order { 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 = id; } @@ -2375,7 +2376,7 @@ public class Order { 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 Customer { @OneToMany(orphanRemoval=true) public Set<Order> getOrders() { return orders; } public void setOrders(Set<Order> orders) { this.orders = orders; } private Set<Order> orders; @@ -2428,7 +2429,7 @@ customer.getOrders().remove(order); //order will be deleted by cascade@IdClass. These are more detailed in . - @Entity + @Entity public class RegionalArticle implements Serializable { @Id @@ -2440,7 +2441,7 @@ public class RegionalArticlePk implements Serializable { ... } or alternatively - @Entity + @Entity public class RegionalArticle implements Serializable { @EmbeddedId @@ -2458,7 +2459,7 @@ public class RegionalArticlePk implements Serializable { ... } - @Entity + @Entity public class Parent implements Serializable { @Id public ParentPk id; @@ -2474,7 +2475,7 @@ public class Parent implements Serializable { ... } - @Entity + @Entity public class Child implements Serializable { @Id @GeneratedValue public Integer id; @@ -2488,7 +2489,7 @@ public class Child implements Serializable { public Parent parent; //unidirectional } - @Embeddable + @Embeddable public class ParentPk implements Serializable { String firstName; String lastName; @@ -2509,7 +2510,7 @@ public class ParentPk implements Serializable { parameter of @Column or @JoinColumn. - @Entity + @Entity @Table(name="MainCat") @SecondaryTables({ @SecondaryTable(name="Cat1", pkJoinColumns={ @@ -2623,7 +2624,7 @@ public class Cat implements Serializable { that. - @Entity @Cacheable + @Entity @Cacheable @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class Forest { ... } @@ -2632,7 +2633,7 @@ public class Forest { ... } @Cache annotation on the collection property. - @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER) + @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER) @JoinColumn(name="CUST_ID") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public SortedSet<Ticket> getTickets() { @@ -2651,7 +2652,7 @@ public SortedSet<Ticket> getTickets() { - @Cache( + @Cache( CacheConcurrencyStrategy usage(); String region() default ""; String include() default "all"; @@ -2708,7 +2709,7 @@ public SortedSet<Ticket> getTickets() { manager factory scope. A named query is defined by its name and the actual query string. - <entity-mappings> + <entity-mappings> <named-query name="plane.getAll"> <query>select p from Plane p</query> </named-query> @@ -2738,7 +2739,6 @@ public class MyDao { The available Hibernate hints are - Query hints @@ -2837,7 +2837,7 @@ public class MyDao { definitions are optional provided that they map to the same column name as the one declared on the class property. - @NamedNativeQuery(name="night&area", query="select night.id nid, night.night_duration, " + @NamedNativeQuery(name="night&area", query="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 = area.id", resultSetMapping="joinMapping") @@ -2863,7 +2863,7 @@ public class MyDao { column name, actually the column name retrieved by the query. Let's now see an implicit declaration of the property / column. - @Entity + @Entity @SqlResultSetMapping(name="implicit", entities=@EntityResult(entityClass=SpaceShip.class)) @NamedNativeQuery(name="implicitSample", @@ -2911,7 +2911,7 @@ public class SpaceShip { property name for the relationship, followed by a dot ("."), followed by the name or the field or property of the primary key. - @Entity + @Entity @SqlResultSetMapping(name="compositekey", entities=@EntityResult(entityClass=SpaceShip.class, fields = { @@ -3014,7 +3014,7 @@ public class Captain implements Serializable { mapping, you can use the resultClass attribute instead of resultSetMapping: - @NamedNativeQuery(name="implicitSample", query="select * from SpaceShip", + @NamedNativeQuery(name="implicitSample", query="select * from SpaceShip", resultClass=SpaceShip.class) public class SpaceShip { @@ -3025,7 +3025,7 @@ public class SpaceShip { and scalar returns in the same native query (this is probably not that common though). - @SqlResultSetMapping(name="scalar", columns=@ColumnResult(name="dimension")) + @SqlResultSetMapping(name="scalar", columns=@ColumnResult(name="dimension")) @NamedNativeQuery(name="scalar", query="select length*width as dimension from SpaceShip", resultSetMapping="scalar") An other query hint specific to native queries has been @@ -3187,7 +3187,7 @@ public class SpaceShip { implements persistence via, for example, stored procedure calls, serialization to flat files or LDAP. - @Entity + @Entity @BatchSize(size=5) @org.hibernate.annotations.Entity( selectBeforeUpdate = true, @@ -3197,7 +3197,9 @@ public class SpaceShip { @Where(clause="1=1") @org.hibernate.annotations.Table(name="Forest", indexes = { @Index(name="idx", columnNames = { "name", "length" } ) } ) @Persister(impl=MyEntityPersister.class) -public class Forest { ... } @Entity +public class Forest { ... } + + @Entity @Inheritance( strategy=InheritanceType.JOINED ) @@ -3222,7 +3224,7 @@ public class Carrot extends Vegetable { ... } allows you to define an Hibernate specific id generator. - @Id @GeneratedValue(generator="system-uuid") + @Id @GeneratedValue(generator="system-uuid") @GenericGenerator(name="system-uuid", strategy = "uuid") public String getId() { @@ -3247,7 +3249,7 @@ public Integer getId() { annotations, making them application level generators (just like if they were in a JPA XML file). - @GenericGenerators( + @GenericGenerators( { @GenericGenerator( name="hibseq", @@ -3275,7 +3277,7 @@ package org.hibernate.test.model composed of all the properties marked @NaturalId. - @Entity + @Entity public class Citizen { @Id @GeneratedValue @@ -3317,7 +3319,7 @@ List results = s.createCriteria( Citizen.class ) property into a column. This kind of property is read only (its value is calculated by your formula fragment). - @Formula("obj_length * obj_height * obj_width") + @Formula("obj_length * obj_height * obj_width") public long getObjectVolume() The SQL fragment can be as complex as you want and even include @@ -3353,7 +3355,7 @@ public long getObjectVolume() Place your annotations before the package declaration. - @TypeDef( + @TypeDef( name = "phoneNumber", defaultForType = PhoneNumber.class, typeClass = PhoneNumberType.class @@ -3372,7 +3374,7 @@ public class ContactDetails { 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( @@ -3397,7 +3399,7 @@ public class Forest { definitions. The @Columns has been introduced for that purpose. - @Type(type="org.hibernate.test.annotations.entity.MonetaryAmountUserType") + @Type(type="org.hibernate.test.annotations.entity.MonetaryAmountUserType") @Columns(columns = { @Column(name="r_amount"), @Column(name="r_currency") @@ -3421,7 +3423,7 @@ public class MonetaryAmount implements Serializable { @Index annotation on a one column property, the columnNames attribute will then be ignored - @Column(secondaryTable="Cat1") + @Column(secondaryTable="Cat1") @Index(name="story1index") public String getStoryPart1() { return storyPart1; @@ -3434,7 +3436,7 @@ public String getStoryPart1() { 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; ... @@ -3457,7 +3459,7 @@ person == person.address.owner 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) @@ -3491,7 +3493,7 @@ public class Antenna { targetEntity attribute available on associations. - @Embedded + @Embedded @Target(OwnerImpl.class) public Owner getOwner() { return owner; @@ -3523,7 +3525,7 @@ public class Antenna { formula for discriminator resolution (no need to have a dedicated column). - @Entity + @Entity @DiscriminatorFormula("case when forest_type is null then 0 else forest_type end") public class Forest { ... } @@ -3538,7 +3540,7 @@ public class Forest { ... } You can define the foreign key name generated by Hibernate for subclass tables in the JOINED inheritance strategy. - @Entity + @Entity @Inheritance(strategy = InheritanceType.JOINED) public abstract class File { ... } @@ -3564,7 +3566,7 @@ public class Document extends File { @ManyToOne, @OneToMany or @ManyToMany association. - @Entity + @Entity public class Child { ... @ManyToOne @@ -3576,7 +3578,7 @@ public class Child { Sometimes you want to delegate to your database the deletion of cascade when a given entity is deleted. - @Entity + @Entity public class Child { ... @ManyToOne @@ -3592,7 +3594,7 @@ public class Child { fairly unreadable name. You can override the constraint name by use @ForeignKey. - @Entity + @Entity public class Child { ... @ManyToOne @@ -3722,7 +3724,7 @@ alter table Child add constraint FK_PARENT foreign key (parent_id) references Pa @AnyDef and @AnyDefs annotations are used. - @Any( metaColumn = @Column( name = "property_type" ), fetch=FetchType.EAGER ) + @Any( metaColumn = @Column( name = "property_type" ), fetch=FetchType.EAGER ) @AnyMetaDef( idType = "integer", metaType = "string", @@ -3743,7 +3745,7 @@ alter table Child add constraint FK_PARENT foreign key (parent_id) references Pa reused. It is recommended to place it as a package metadata in this case. - //on a package + //on a package @AnyMetaDef( name="property" idType = "integer", metaType = "string", @@ -3816,7 +3818,7 @@ package org.hibernate.test.annotations.any; SortedSet or a SortedMap interface. - @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER) + @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER) @JoinColumn(name="CUST_ID") @Sort(type = SortType.COMPARATOR, comparator = TicketComparator.class) @Where(clause="1=1") @@ -3835,7 +3837,7 @@ package org.hibernate.test.annotations.any; inverseName referencing to the other side constraint. - @Entity + @Entity public class Woman { ... @ManyToMany(cascade = {CascadeType.ALL}) @@ -3861,7 +3863,7 @@ alter table Man_Woman add constraint TO_MAN_FK foreign key (man_id) references M associated class explicitly maps the indexed value, the use of mappedBy is permitted: - @Entity + @Entity public class Parent { @OneToMany(mappedBy="parent") @OrderColumn(name="order") @@ -3889,7 +3891,7 @@ public class Child { the collection as mappedBy. Instead, we could use the following mapping: - @Entity + @Entity public class Parent { @OneToMany @OrderColumn(name="order") @@ -3925,7 +3927,7 @@ public class Child { generator strategy. The strategy can be identity, or any defined generator name of your application. - @Entity + @Entity @TableGenerator(name="ids_generator", table="IDS") public class Passport { ... @@ -3955,7 +3957,7 @@ public class Passport { only in very special cases (eg. audit logs, user session data, etc). - @ManyToAny( + @ManyToAny( metaColumn = @Column( name = "property_type" ) ) @AnyMetaDef( idType = "integer", @@ -4033,7 +4035,7 @@ public class Passport { PERSIST at flush time as per the specification). - @OneToMany( cascade = {CascadeType.PERSIST, CascadeType.MERGE} ) + @OneToMany( cascade = {CascadeType.PERSIST, CascadeType.MERGE} ) @Cascade(org.hibernate.annotations.CascadeType.REPLICATE) public Collection<Employer> getEmployers() @@ -4065,7 +4067,7 @@ public Collection<Employer> getEmployers() entity load or the collection load. @Filter is used and placed either on the entity or the collection element - @Entity + @Entity @FilterDef(name="minLength", parameters=@ParamDef( name="minLength", type="integer" ) ) @Filters( { @Filter(name="betweenLength", condition=":minLength <= length and :maxLength >= length"), @@ -4081,7 +4083,7 @@ public class Forest { ... } association table, use the @FilterJoinTable annotation. - @OneToMany + @OneToMany @JoinTable //filter on the target entity table @Filter(name="betweenLength", condition=":minLength <= length and :maxLength >= length") @@ -4159,7 +4161,7 @@ public class Forest { ... } you can also override the SQL statement used to load or change the state of entities. - @Entity + @Entity @Table(name="CHAOS") @SQLInsert( sql="INSERT INTO CHAOS(size, name, nickname, id) VALUES(?,upper(?),?,?)") @SQLUpdate( sql="UPDATE CHAOS SET size = ?, name = upper(?), nickname = ? WHERE id = ?") @@ -4214,7 +4216,7 @@ public class Chaos { You can use the exact same set of annotations to override the collection related statements. - @OneToMany + @OneToMany @JoinColumn(name="chaos_fk") @SQLInsert( sql="UPDATE CASIMIR_PARTICULE SET chaos_fk = ? where id = ?") @SQLDelete( sql="UPDATE CASIMIR_PARTICULE SET chaos_fk = null where id = ?") @@ -4234,7 +4236,7 @@ private Set<CasimirParticle> particles = new HashSet<CasimirParticle> all) attributes sqlInsert, sqlUpdate, sqlDelete: - @Entity + @Entity @SecondaryTables({ @SecondaryTable(name = "`Cat nbr1`"), @SecondaryTable(name = "Cat2"}) @@ -4274,7 +4276,7 @@ public class Cat implements Serializable { To define tuplixer in annotations, simply use the @Tuplizer annotation on the according element - @Entity + @Entity @Tuplizer(impl = DynamicEntityTuplizer.class) public interface Cuisine { @Id @@ -4304,7 +4306,7 @@ public interface Cuisine { fetch profile will be in affect for that session until it is explicitly disabled. Lets look at an example: - @Entity + @Entity @FetchProfile(name = "customer-with-orders", fetchOverrides = { @FetchProfile.FetchOverride(entity = Customer.class, association = "orders", mode = FetchMode.JOIN) }) @@ -4323,12 +4325,13 @@ public class Customer { // standard getter/setter ... } - 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 + + 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 = ...; + Session session = ...; session.enableFetchProfile( "customer-with-orders" ); // name matches @FetchProfile name Customer customer = (Customer) session.get( Customer.class, customerId ); session.disableFetchProfile( "customer-with-orders" ); // or just close the session @@ -4350,4 +4353,4 @@ session.disableFetchProfile( "customer-with-orders" ); // or just close the sess Hibernate Core documentation. - + \ No newline at end of file diff --git a/annotations/src/main/docbook/en/modules/setup.xml b/annotations/src/main/docbook/en/modules/setup.xml index 7cbe684340..b35ba33e4f 100644 --- a/annotations/src/main/docbook/en/modules/setup.xml +++ b/annotations/src/main/docbook/en/modules/setup.xml @@ -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> @@ -96,9 +96,9 @@ or above from the Hibernate website and add hibernate-validator.jar and validation-api.jar in your classpath. Alternatively - add the following dependency in your - pom.xml. - <project> + add the following dependency in your pom.xml. + + <project> ... <dependencies> <dependency> @@ -117,7 +117,9 @@ 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> @@ -138,7 +140,8 @@ AnnotationConfiguration class instead of the Configuration class. Here is an example using the (legacy) HibernateUtil approach: - package hello; + + package hello; import org.hibernate.*; import org.hibernate.cfg.*; @@ -171,7 +174,7 @@ private static final SessionFactory sessionFactory; hibernate.cfg.xml). Here is the equivalent of the above declaration: - <!DOCTYPE hibernate-configuration PUBLIC + <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> @@ -194,7 +197,8 @@ private static final SessionFactory sessionFactory; Alternatively, you can define the annotated classes and packages using the programmatic API - sessionFactory = new AnnotationConfiguration() + sessionFactory = new AnnotationConfiguration() .addPackage("test.animals") //the fully qualified package name .addAnnotatedClass(Flight.class) .addAnnotatedClass(Sky.class) @@ -321,4 +325,4 @@ private static final SessionFactory sessionFactory; url="http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#configuration-logging">Logging in the Hibernate Core documentation. - + \ No newline at end of file diff --git a/annotations/src/main/docbook/en/modules/xml-overriding.xml b/annotations/src/main/docbook/en/modules/xml-overriding.xml index cc6d07b5b0..1f61c4090b 100644 --- a/annotations/src/main/docbook/en/modules/xml-overriding.xml +++ b/annotations/src/main/docbook/en/modules/xml-overriding.xml @@ -1,4 +1,4 @@ - + - - + Overriding metadata through XML @@ -44,7 +44,7 @@ the annotations one. So if you know the annotations structure, using the XML schema will be straightforward for you. - You can define one ot more XML files describing your metadata, these + You can define one or more XML files describing your metadata, these files will be merged by the overriding engine.
@@ -53,7 +53,7 @@ You can define global level metadata available for all XML files. You must not define these metadata more than once per deployment. - <?xml version="1.0" encoding="UTF-8"?> + <?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" @@ -347,7 +347,7 @@ mapped-superclass/attributes or embeddable/attributes. - <attributes> + <attributes> <id name="id"> <column name="fld_id"/> <generated-value generator="generator" strategy="SEQUENCE"/> @@ -388,7 +388,7 @@ mapped-superclass/attributes or embeddable/attributes. - <attributes> + <attributes> <one-to-many name="players" fetch="EAGER"> <map-key name="name"/> <join-column name="driver"/> @@ -424,4 +424,4 @@ informations in the chapter describing annotations.
-
+ \ No newline at end of file