Hibernate SVN: r18913 - in core/branches/Branch_3_2_4_SP1_CP: test/org/hibernate/test/unionsubclass and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-03-01 08:32:12 -0500 (Mon, 01 Mar 2010)
New Revision: 18913
Added:
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/CarBuyer.java
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/Customer.java
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/PersonID.java
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/SellCarTest.java
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/Seller.java
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/mapping.hbm.xml
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/persister/collection/AbstractCollectionPersister.java
Log:
JBPAPP-3487 HHH-4825 wrong alias used in table-pre-class Inheritance strategy
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/persister/collection/AbstractCollectionPersister.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/persister/collection/AbstractCollectionPersister.java 2010-03-01 13:27:48 UTC (rev 18912)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/persister/collection/AbstractCollectionPersister.java 2010-03-01 13:32:12 UTC (rev 18913)
@@ -277,7 +277,7 @@
// NativeSQL: collect key column and auto-aliases
Column col = ( (Column) iter.next() );
keyColumnNames[k] = col.getQuotedName(dialect);
- keyColumnAliases[k] = col.getAlias(dialect);
+ keyColumnAliases[k] = col.getAlias(dialect,collection.getOwner().getRootTable());
k++;
}
Added: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/CarBuyer.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/CarBuyer.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/CarBuyer.java 2010-03-01 13:32:12 UTC (rev 18913)
@@ -0,0 +1,59 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+/**
+ *
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public class CarBuyer extends Customer {
+ private String sellerName;
+ private String pid;
+ private Seller seller;
+
+ public String getSellerName() {
+ return sellerName;
+ }
+
+ public void setSellerName( String sellerName ) {
+ this.sellerName = sellerName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid( String pid ) {
+ this.pid = pid;
+ }
+
+ public Seller getSeller() {
+ return seller;
+ }
+
+ public void setSeller( Seller seller ) {
+ this.seller = seller;
+ }
+
+}
Added: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/Customer.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/Customer.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/Customer.java 2010-03-01 13:32:12 UTC (rev 18913)
@@ -0,0 +1,57 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public abstract class Customer implements Serializable {
+ private PersonID id;
+
+ public PersonID getId() {
+ return id;
+ }
+
+ public void setId( PersonID id ) {
+ this.id = id;
+ }
+
+ public boolean equals( Object obj ) {
+ if ( obj == null )
+ return false;
+ if ( obj == this )
+ return true;
+ if ( !( obj instanceof Customer ) )
+ return false;
+ return ( (Customer) obj ).getId().equals( getId() );
+ }
+
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+}
Added: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/PersonID.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/PersonID.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/PersonID.java 2010-03-01 13:32:12 UTC (rev 18913)
@@ -0,0 +1,94 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public class PersonID implements Serializable {
+ private Long num;
+ private String name;
+
+ public Long getNum() {
+ return num;
+ }
+
+ public void setNum( Long num ) {
+ this.num = num;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ public boolean equals( Object obj ) {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ final PersonID other = (PersonID) obj;
+ if ( name == null ) {
+ if ( other.name != null )
+ return false;
+
+ } else if ( !name.equals( other.name ) ) {
+ return false;
+ }
+ if ( num == null ) {
+ if ( other.num != null )
+ return false;
+
+ } else if ( !num.equals( other.num ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ if ( name != null ) {
+ result += name.hashCode();
+ }
+ result *= PRIME;
+ if ( num != null ) {
+ result += num.hashCode();
+ }
+ return result;
+ }
+
+ public String toString() {
+ return name + " | " + num;
+ }
+
+}
Added: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/SellCarTest.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/SellCarTest.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/SellCarTest.java 2010-03-01 13:32:12 UTC (rev 18913)
@@ -0,0 +1,82 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+
+/**
+ * http://opensource.atlassian.com/projects/hibernate/browse/HHH-4825
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public class SellCarTest extends FunctionalTestCase {
+
+ public SellCarTest( String string ) {
+ super( string );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "unionsubclass/alias/mapping.hbm.xml" };
+ }
+
+ public void testSellCar() throws Exception {
+ prepareData();
+ Session session = openSession();
+ Transaction tx = session.beginTransaction();
+ Query query = session.createQuery( "from Seller" );
+ Seller seller = (Seller) query.uniqueResult();
+ assertNotNull( seller );
+ assertEquals( 1, seller.getBuyers().size() );
+ tx.commit();
+ session.close();
+ }
+
+ private void prepareData() {
+ Session session = openSession();
+ Transaction tx = session.beginTransaction();
+ session.save( createData() );
+ tx.commit();
+ session.close();
+ }
+
+ private Object createData() {
+ Seller stliu = new Seller();
+ stliu.setId( createID( "stliu" ) );
+ CarBuyer zd = new CarBuyer();
+ zd.setId( createID( "zd" ) );
+ zd.setSeller( stliu );
+ zd.setSellerName( stliu.getId().getName() );
+ stliu.getBuyers().add( zd );
+ return stliu;
+ }
+
+ private PersonID createID( String name ) {
+ PersonID id = new PersonID();
+ id.setName( name );
+ id.setNum( new Long( 100 ) );
+ return id;
+ }
+}
Added: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/Seller.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/Seller.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/Seller.java 2010-03-01 13:32:12 UTC (rev 18913)
@@ -0,0 +1,69 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ *
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public class Seller implements Serializable {
+ private PersonID id;
+ private Set buyers = new HashSet();
+
+ public PersonID getId() {
+ return id;
+ }
+
+ public void setId( PersonID id ) {
+ this.id = id;
+ }
+
+ public Set getBuyers() {
+ return buyers;
+ }
+
+ public void setBuyers( Set buyers ) {
+ this.buyers = buyers;
+ }
+
+ public boolean equals( Object obj ) {
+ if ( obj == null )
+ return false;
+ if ( obj == this )
+ return true;
+ if ( !( obj instanceof Seller ) )
+ return false;
+
+ return ( (Seller) obj ).getId().equals( getId() );
+ }
+
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+}
Added: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/mapping.hbm.xml
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/mapping.hbm.xml (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/unionsubclass/alias/mapping.hbm.xml 2010-03-01 13:32:12 UTC (rev 18913)
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping package="org.hibernate.test.unionsubclass.alias">
+
+ <class name="Seller">
+ <composite-id class="PersonID" name="id">
+ <key-property column="NR_RZBK" name="num" />
+ <key-property column="TXT_OID" name="name" />
+ </composite-id>
+ <set cascade="persist, merge, save-update" inverse="true" lazy="false"
+ name="buyers">
+ <key>
+ <column name="NR_RZBK" />
+ <column name="TXT_OID_TESTB" />
+ </key>
+ <one-to-many class="CarBuyer" />
+ </set>
+ </class>
+
+ <class abstract="true" name="Customer">
+ <composite-id class="PersonID" name="id">
+ <key-property column="NR_RZBK" name="num" />
+ <key-property column="TXT_OID" name="name" />
+ </composite-id>
+ <union-subclass name="CarBuyer">
+ <property column="PID" name="pid" update="false" />
+ <property column="TXT_OID_TESTB" name="sellerName" />
+ <many-to-one cascade="persist, merge, save-update" class="Seller"
+ insert="false" name="seller" update="false">
+ <column name="NR_RZBK" />
+ <column name="TXT_OID_TESTB" />
+ </many-to-one>
+ </union-subclass>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
14 years, 9 months
Hibernate SVN: r18912 - core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-03-01 08:27:48 -0500 (Mon, 01 Mar 2010)
New Revision: 18912
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/ConnectionProviderFactory.java
Log:
correct javadoc typo
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/ConnectionProviderFactory.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/ConnectionProviderFactory.java 2010-03-01 13:26:56 UTC (rev 18911)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/connection/ConnectionProviderFactory.java 2010-03-01 13:27:48 UTC (rev 18912)
@@ -60,7 +60,7 @@
* Instantiate a <tt>ConnectionProvider</tt> using given properties.
* Method newConnectionProvider.
* @param properties hibernate <tt>SessionFactory</tt> properties
- * @param connectionProviderInjectionData object to be injected in the conenction provided
+ * @param connectionProviderInjectionData object to be injected in the connection provided
* @return ConnectionProvider
* @throws HibernateException
*/
@@ -132,7 +132,7 @@
* Transform JDBC connection properties.
*
* Passed in the form <tt>hibernate.connection.*</tt> to the
- * format accepted by <tt>DriverManager</tt> by triming the leading "<tt>hibernate.connection</tt>".
+ * format accepted by <tt>DriverManager</tt> by trimming the leading "<tt>hibernate.connection</tt>".
*/
public static Properties getConnectionProperties(Properties properties) {
14 years, 9 months
Hibernate SVN: r18911 - in core/trunk/annotations/src/main: java/org/hibernate/annotations and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-03-01 08:26:56 -0500 (Mon, 01 Mar 2010)
New Revision: 18911
Modified:
core/trunk/annotations/src/main/docbook/en/modules/entity.xml
core/trunk/annotations/src/main/java/org/hibernate/annotations/MapKey.java
core/trunk/annotations/src/main/java/org/hibernate/annotations/MapKeyManyToMany.java
Log:
HHH-4933 Doc on Map and List support
Modified: core/trunk/annotations/src/main/docbook/en/modules/entity.xml
===================================================================
--- core/trunk/annotations/src/main/docbook/en/modules/entity.xml 2010-03-01 13:23:33 UTC (rev 18910)
+++ core/trunk/annotations/src/main/docbook/en/modules/entity.xml 2010-03-01 13:26:56 UTC (rev 18911)
@@ -24,7 +24,7 @@
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="entity">
- <title>Entity Beans</title>
+ <title>Mapping Entities</title>
<section id="entity-overview" revision="2">
<title>Intro</title>
@@ -957,7 +957,7 @@
identifier. In the database, it means that the
<literal>Customer.user</literal> and the
<literal>CustomerId.userId</literal> properties share the same
- underlying column (<literal>user_fk</literal> in this case). </para>
+ underlying column (<literal>user_fk</literal> in this case).</para>
<para>In practice, your code only sets the
<literal>Customer.user</literal> property and the user id value is
@@ -966,7 +966,7 @@
<warning>
<para>The id value can be copied as late as flush time, don't rely
- on it until after flush time. </para>
+ on it until after flush time.</para>
</warning>
<para>While not supported in JPA, Hibernate lets you place your
@@ -1399,7 +1399,7 @@
</section>
<section id="entity-mapping-association">
- <title>Mapping entity bean associations/relationships</title>
+ <title>Mapping entity associations/relationships</title>
<section>
<title>One-to-one</title>
@@ -1493,7 +1493,7 @@
<literal>passport</literal> and the column id of <literal>Passport
</literal>is <literal>id</literal>.</para>
- <para>The third possibility (using an association table) is very
+ <para>The third possibility (using an association table) is quite
exotic.</para>
<programlisting>
@@ -1536,8 +1536,7 @@
<para>Many-to-one associations are declared at the property level with
the annotation <literal>@ManyToOne</literal>:</para>
- <programlisting>
-@Entity()
+ <programlisting>@Entity()
public class Flight implements Serializable {
<emphasis role="bold">@ManyToOne</emphasis>( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumn(name="COMP_ID")
@@ -1545,8 +1544,7 @@
return company;
}
...
-}
- </programlisting>
+} </programlisting>
<para>The <literal>@JoinColumn</literal> attribute is optional, the
default value(s) is like in one to one, the concatenation of the name
@@ -1563,8 +1561,7 @@
almost all cases. However this is useful when you want to use
interfaces as the return type instead of the regular entity.</para>
- <programlisting>
-@Entity()
+ <programlisting>@Entity
public class Flight implements Serializable {
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE}, <emphasis
role="bold">targetEntity=CompanyImpl.class</emphasis> )
@@ -1577,9 +1574,9 @@
public interface Company {
...
- </programlisting>
+}</programlisting>
- <para>You can alse map a many to one association through an
+ <para>You can also map a many-to-one association through an
association table. This association table described by the
<literal>@JoinTable</literal> annotation will contains a foreign key
referencing back the entity table (through
@@ -1587,8 +1584,7 @@
referencing the target entity table (through
<literal>@JoinTable.inverseJoinColumns</literal>).</para>
- <programlisting>
-@Entity()
+ <programlisting>@Entity
public class Flight implements Serializable {
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
<emphasis role="bold">@JoinTable(name="Flight_Company",
@@ -1599,8 +1595,7 @@
return company;
}
...
-}
- </programlisting>
+} </programlisting>
</section>
<section id="entity-mapping-association-collections" revision="1">
@@ -1611,37 +1606,267 @@
<title>Overview</title>
<para>You can map <classname>Collection</classname>,
- <literal>List</literal> (ie ordered lists, not indexed lists),
- <literal>Map</literal> and <classname>Set</classname>. The EJB3
- specification describes how to map an ordered list (ie a list
- ordered at load time) using
- <literal>@javax.persistence.OrderBy</literal> annotation: this
- annotation takes into parameter a list of comma separated (target
- entity) properties to order the collection by (eg <code>firstname
- asc, age desc</code>), if the string is empty, the collection will
- be ordered by id. For true indexed collections, please refer to the
- <xref linkend="entity-hibspec" />. EJB3 allows you to map Maps using
- as a key one of the target entity property using
- <literal>@MapKey(name="myProperty")</literal> (myProperty is a
- property name in the target entity). When using
- <literal>@MapKey</literal> (without property name), the target
- entity primary key is used. The map key uses the same column as the
- property pointed out: there is no additional column defined to hold
- the map key, and it does make sense since the map key actually
- represent a target property. Be aware that once loaded, the key is
- no longer kept in sync with the property, in other words, if you
- change the property value, the key will not change automatically in
- your Java model (for true map support please refers to <xref
- linkend="entity-hibspec" />). Many people confuse
- <literal><map></literal> capabilities and
- <literal>@MapKey</literal> ones. These are two different features.
- <literal>@MapKey</literal> still has some limitations, please check
- the forum or the JIRA tracking system for more informations.</para>
+ <classname>List</classname>, <classname>Map</classname> and
+ <classname>Set</classname> pointing to associated entities as
+ one-to-many or many-to-many associations using the
+ <classname>@OneToMany</classname> or
+ <classname>@ManyToMany</classname> annotation respectively. If the
+ collection is of a basic type or of an embeddable type, use
+ <classname>@ElementCollection</classname>. We will describe that in
+ more detail in the following subsections but let's first focus on
+ some semantic differences between the various collections.</para>
- <para>Hibernate has several notions of collections.</para>
+ <para>Lists can be mapped in two different ways:</para>
- <para></para>
+ <itemizedlist>
+ <listitem>
+ <para>as ordered lists, the order is not materialized in the
+ database</para>
+ </listitem>
+ <listitem>
+ <para>as indexed lists, the order is materialized in the
+ database</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>To order lists in memory, add
+ <literal>@javax.persistence.OrderBy</literal> to your property. This
+ annotation takes into parameter a list of comma separated properties
+ (of the target entity) and order the collection accordingly (eg
+ <code>firstname asc, age desc</code>), if the string is empty, the
+ collection will be ordered by the primary key of the target
+ entity.</para>
+
+ <programlisting>@Entity
+public class Customer {
+ @Id @GeneratedValue public Integer getId() { return id; }
+ public void setId(Integer id) { this.id = id; }
+ private Integer id;
+
+ @OneToMany(mappedBy="customer")
+ <emphasis role="bold">@OrderBy("number")</emphasis>
+ public List<Order> getOrders() { return orders; }
+ public void setOrders(List<Order> orders) { this.orders = orders; }
+ private List<Order> orders;
+}
+
+@Entity
+public class Order {
+ @Id @GeneratedValue public Integer getId() { return id; }
+ public void setId(Integer id) { this.id = id; }
+ private Integer id;
+
+ public String getNumber() { return number; }
+ public void setNumber(String number) { this.number = number; }
+ private String number;
+
+ @ManyToOne
+ public Customer getCustomer() { return customer; }
+ public void setCustomer(Customer customer) { this.customer = customer; }
+ private Customer number;
+}
+
+-- Table schema
+|-------------| |----------|
+| Order | | Customer |
+|-------------| |----------|
+| id | | id |
+| number | |----------|
+| customer_id |
+|-------------|</programlisting>
+
+ <para>To store the index value in a dedicated column, use the
+ <classname>@javax.persistence.OrderColumn</classname> annotation on
+ your property. This annotations describes the column name and
+ attributes of the column keeping the index value. This column is
+ hosted on the table containing the association foreign key. If the
+ column name is not specified, the default is the name of the
+ referencing property, followed by underscore, followed by
+ <literal>ORDER</literal> (in the following example, it would be
+ <literal>orders_ORDER</literal>).</para>
+
+ <programlisting>@Entity
+public class Customer {
+ @Id @GeneratedValue public Integer getId() { return id; }
+ public void setId(Integer id) { this.id = id; }
+ private Integer id;
+
+ @OneToMany(mappedBy="customer")
+ <emphasis role="bold">@OrderColumn(name"orders_index")</emphasis>
+ public List<Order> getOrders() { return orders; }
+ public void setOrders(List<Order> orders) { this.orders = orders; }
+ private List<Order> orders;
+}
+
+@Entity
+public class Order {
+ @Id @GeneratedValue public Integer getId() { return id; }
+ public void setId(Integer id) { this.id = id; }
+ private Integer id;
+
+ public String getNumber() { return number; }
+ public void setNumber(String number) { this.number = number; }
+ private String number;
+
+ @ManyToOne
+ public Customer getCustomer() { return customer; }
+ public void setCustomer(Customer customer) { this.customer = customer; }
+ private Customer number;
+}
+
+-- Table schema
+|--------------| |----------|
+| Order | | Customer |
+|--------------| |----------|
+| id | | id |
+| number | |----------|
+| customer_id |
+| orders_index |
+|--------------|</programlisting>
+
+ <note>
+ <para>We recommend you to convert
+ <classname>@org.hibernate.annotations.IndexColumn</classname>
+ usages to <classname>@OrderColumn</classname> unless you are
+ making use of the base property. The <literal>base</literal>
+ property lets you define the index value of the first element (aka
+ as base index). The usual value is <literal>0</literal> or
+ <literal>1</literal>. The default is 0 like in Java.</para>
+ </note>
+
+ <para>Likewise, maps can borrow their keys from one of the
+ associated entity properties or have dedicated columns to store an
+ explicit key.</para>
+
+ <para>To use one of the target entity property as a key of the map,
+ use <literal>@MapKey(name="myProperty")</literal>
+ (<literal>myProperty</literal> is a property name in the target
+ entity). When using <literal>@MapKey</literal> (without property
+ name), the target entity primary key is used. The map key uses the
+ same column as the property pointed out: there is no additional
+ column defined to hold the map key, and it does make sense since the
+ map key actually represent a target property. Be aware that once
+ loaded, the key is no longer kept in sync with the property, in
+ other words, if you change the property value, the key will not
+ change automatically in your Java model.</para>
+
+ <programlisting>@Entity
+public class Customer {
+ @Id @GeneratedValue public Integer getId() { return id; }
+ public void setId(Integer id) { this.id = id; }
+ private Integer id;
+
+ @OneToMany(mappedBy="customer")
+ <emphasis role="bold">@MapKey(name"number")</emphasis>
+ public Map<String,Order> getOrders() { return orders; }
+ public void setOrders(Map<String,Order> order) { this.orders = orders; }
+ private Map<String,Order> orders;
+}
+
+@Entity
+public class Order {
+ @Id @GeneratedValue public Integer getId() { return id; }
+ public void setId(Integer id) { this.id = id; }
+ private Integer id;
+
+ public String getNumber() { return number; }
+ public void setNumber(String number) { this.number = number; }
+ private String number;
+
+ @ManyToOne
+ public Customer getCustomer() { return customer; }
+ public void setCustomer(Customer customer) { this.customer = customer; }
+ private Customer number;
+}
+
+-- Table schema
+|-------------| |----------|
+| Order | | Customer |
+|-------------| |----------|
+| id | | id |
+| number | |----------|
+| customer_id |
+|-------------|</programlisting>
+
+ <para>Otherwise, the map key is mapped to a dedicated column or
+ columns. To customize things, use one of the following
+ annotations:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>@<classname>MapKeyColumn</classname> if the map key is a
+ basic type, if you don't specify the column name, the name of
+ the property followed by underscore followed by
+ <literal>KEY</literal> is used (for example
+ <literal>orders_KEY</literal>).</para>
+ </listitem>
+
+ <listitem>
+ <para><classname>@MapKeyEnumerated</classname> /
+ <classname>@MapKeyTemporal</classname> if the map key type is
+ respectively an enum or a <classname>Date</classname>.</para>
+ </listitem>
+
+ <listitem>
+ <para><classname>@MapKeyJoinColumn</classname>/<classname>@MapKeyJoinColumns</classname>
+ if the map key type is another entity.</para>
+ </listitem>
+
+ <listitem>
+ <para><classname>@AttributeOverride</classname>/<classname>@AttributeOverrides</classname>
+ when the map key is a embeddable object. Use
+ <literal>key.</literal> as a prefix for your embeddable object
+ property names.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>You can also use <classname>@MapKeyClass</classname> to define
+ the type of the key if you don't use generics (at this stage, you
+ should wonder why at this day and age you don't use
+ generics).</para>
+
+ <programlisting>@Entity
+public class Customer {
+ @Id @GeneratedValue public Integer getId() { return id; }
+ public void setId(Integer id) { this.id = id; }
+ private Integer id;
+
+ @OneToMany @JoinTable(name="Cust_Order")
+ <emphasis role="bold">@MapKeyColumn(name"orders_number")</emphasis>
+ public Map<String,Order> getOrders() { return orders; }
+ public void setOrders(Map<String,Order> orders) { this.orders = orders; }
+ private Map<String,Order> orders;
+}
+
+@Entity
+public class Order {
+ @Id @GeneratedValue public Integer getId() { return id; }
+ public void setId(Integer id) { this.id = id; }
+ private Integer id;
+
+ public String getNumber() { return number; }
+ public void setNumber(String number) { this.number = number; }
+ private String number;
+
+ @ManyToOne
+ public Customer getCustomer() { return customer; }
+ public void setCustomer(Customer customer) { this.customer = customer; }
+ private Customer number;
+}
+
+-- Table schema
+|-------------| |----------| |---------------|
+| Order | | Customer | | Cust_Order |
+|-------------| |----------| |---------------|
+| id | | id | | customer_id |
+| number | |----------| | order_id |
+| customer_id | | orders_number |
+|-------------| |---------------|</programlisting>
+
+ <para>Let's now explore the various collection semantics based on
+ the mapping you are choosing.</para>
+
<table>
<title>Collections semantics</title>
@@ -1668,18 +1893,18 @@
<entry>java.util.List, java.util.Collection</entry>
- <entry>@org.hibernate.annotations.CollectionOfElements or
- @OneToMany or @ManyToMany</entry>
+ <entry>@ElementCollection or @OneToMany or
+ @ManyToMany</entry>
</row>
<row>
- <entry>Bag semantic with primary key (withtout the
+ <entry>Bag semantic with primary key (without the
limitations of Bag semantic)</entry>
<entry>java.util.List, java.util.Collection</entry>
- <entry>(@org.hibernate.annotations.CollectionOfElements or
- @OneToMany or @ManyToMany) and @CollectionId</entry>
+ <entry>(@ElementCollection or @OneToMany or @ManyToMany) and
+ @CollectionId</entry>
</row>
<row>
@@ -1687,9 +1912,9 @@
<entry>java.util.List</entry>
- <entry>(@org.hibernate.annotations.CollectionOfElements or
- @OneToMany or @ManyToMany) and
- @org.hibernate.annotations.IndexColumn</entry>
+ <entry>(@ElementCollection or @OneToMany or @ManyToMany) and
+ (@OrderColumn or
+ @org.hibernate.annotations.IndexColumn)</entry>
</row>
<row>
@@ -1697,8 +1922,8 @@
<entry>java.util.Set</entry>
- <entry>@org.hibernate.annotations.CollectionOfElements or
- @OneToMany or @ManyToMany</entry>
+ <entry>@ElementCollection or @OneToMany or
+ @ManyToMany</entry>
</row>
<row>
@@ -1706,75 +1931,20 @@
<entry>java.util.Map</entry>
- <entry>(@org.hibernate.annotations.CollectionOfElements or
- @OneToMany or @ManyToMany) and (nothing or
- @org.hibernate.annotations.MapKey/MapKeyManyToMany for true
- map support, OR @javax.persistence.MapKey</entry>
+ <entry>(@ElementCollection or @OneToMany or @ManyToMany) and
+ ((nothing or @MapKeyJoinColumn/@MapKeyColumn for true map
+ support) OR @javax.persistence.MapKey)</entry>
</row>
</tbody>
</tgroup>
</table>
- <remark>So specifically, java.util.List collections without
- @org.hibernate.annotations.IndexColumn are going to be considered as
+ <remark>Specifically, java.util.List collections without
+ @OrderColumn or @IndexColumn are going to be considered as
bags.</remark>
- <para>Collection of primitive, core type or embedded objects is not
- supported by the EJB3 specification. Hibernate Annotations allows
- them however (see <xref linkend="entity-hibspec" />).</para>
-
- <programlisting>@Entity public class City {
- @OneToMany(mappedBy="city")
- <emphasis role="bold">@OrderBy("streetName")</emphasis>
- public List<Street> getStreets() {
- return streets;
- }
-...
-}
-
-@Entity public class Street {
- <emphasis role="bold">public String getStreetName()</emphasis> {
- return streetName;
- }
-
- @ManyToOne
- public City getCity() {
- return city;
- }
- ...
-}
-
-
-@Entity
-public class Software {
- @OneToMany(mappedBy="software")
- <emphasis role="bold">@MapKey(name="codeName")</emphasis>
- public Map<String, Version> getVersions() {
- return versions;
- }
-...
-}
-
-@Entity
-@Table(name="tbl_version")
-public class Version {
- <emphasis role="bold">public String getCodeName()</emphasis> {...}
-
- @ManyToOne
- public Software getSoftware() { ... }
-...
-}</programlisting>
-
- <para>So <literal>City</literal> has a collection of
- <literal>Street</literal>s that are ordered by
- <literal>streetName</literal> (of <literal>Street</literal>) when
- the collection is loaded. <literal>Software</literal> has a map of
- <literal>Version</literal>s which key is the
- <literal>Version</literal> <literal>codeName</literal>.</para>
-
- <para>Unless the collection is a generic, you will have to define
- <literal>targetEntity</literal>. This is a annotation attribute that
- take the target entity class as a value.</para>
+ <para>More support for collections are available via Hibernate
+ specific extensions (see <xref linkend="entity-hibspec" />).</para>
</section>
<section id="entity-mapping-association-collection-onetomany"
@@ -4171,4 +4341,4 @@
}</programlisting>
</section>
</section>
-</chapter>
\ No newline at end of file
+</chapter>
Modified: core/trunk/annotations/src/main/java/org/hibernate/annotations/MapKey.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/annotations/MapKey.java 2010-03-01 13:23:33 UTC (rev 18910)
+++ core/trunk/annotations/src/main/java/org/hibernate/annotations/MapKey.java 2010-03-01 13:26:56 UTC (rev 18911)
@@ -32,13 +32,17 @@
/**
* Define the map key columns as an explicit column holding the map key
- * This is completly different from {@link javax.persistence.MapKey} which use an existing column
+ * This is completely different from {@link javax.persistence.MapKey} which use an existing column
* This annotation and {@link javax.persistence.MapKey} are mutually exclusive
*
+ * @deprecated Use {@link javax.persistence.MapKeyColumn}
+ * This is the default behavior for Map properties marked as @OneToMany, @ManyToMany
+ * or @ElementCollection
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
+@Deprecated
public @interface MapKey {
Column[] columns() default {};
/**
Modified: core/trunk/annotations/src/main/java/org/hibernate/annotations/MapKeyManyToMany.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/annotations/MapKeyManyToMany.java 2010-03-01 13:23:33 UTC (rev 18910)
+++ core/trunk/annotations/src/main/java/org/hibernate/annotations/MapKeyManyToMany.java 2010-03-01 13:26:56 UTC (rev 18911)
@@ -31,13 +31,17 @@
/**
* Define the map key columns as an explicit column holding the map key
- * This is completly different from {@link javax.persistence.MapKey} which use an existing column
+ * This is completely different from {@link javax.persistence.MapKey} which use an existing column
* This annotation and {@link javax.persistence.MapKey} are mutually exclusive
*
+ * @deprecated Use {@link javax.persistence.MapKeyJoinColumn} {@link javax.persistence.MapKeyJoinColumns}
+ * This is the default behavior for Map properties marked as @OneToMany, @ManyToMany
+ * or @ElementCollection
* @author Emmanuel Bernard
*/
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
+@Deprecated
public @interface MapKeyManyToMany {
JoinColumn[] joinColumns() default {};
/**
14 years, 9 months
Hibernate SVN: r18910 - in core/branches/Branch_3_3_2_GA_CP: testsuite/src/test/java/org/hibernate/test/unionsubclass and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-03-01 08:23:33 -0500 (Mon, 01 Mar 2010)
New Revision: 18910
Added:
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/CarBuyer.java
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/Customer.java
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/PersonID.java
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/SellCarTest.java
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/Seller.java
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/mapping.hbm.xml
Modified:
core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
Log:
JBPAPP-3487 HHH-4825 wrong alias used in table-pre-class Inheritance strategy
Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java 2010-03-01 13:11:22 UTC (rev 18909)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java 2010-03-01 13:23:33 UTC (rev 18910)
@@ -299,7 +299,7 @@
// NativeSQL: collect key column and auto-aliases
Column col = ( (Column) iter.next() );
keyColumnNames[k] = col.getQuotedName(dialect);
- keyColumnAliases[k] = col.getAlias(dialect);
+ keyColumnAliases[k] = col.getAlias(dialect,collection.getOwner().getRootTable());
k++;
}
Added: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/CarBuyer.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/CarBuyer.java (rev 0)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/CarBuyer.java 2010-03-01 13:23:33 UTC (rev 18910)
@@ -0,0 +1,59 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+/**
+ *
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public class CarBuyer extends Customer {
+ private String sellerName;
+ private String pid;
+ private Seller seller;
+
+ public String getSellerName() {
+ return sellerName;
+ }
+
+ public void setSellerName( String sellerName ) {
+ this.sellerName = sellerName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid( String pid ) {
+ this.pid = pid;
+ }
+
+ public Seller getSeller() {
+ return seller;
+ }
+
+ public void setSeller( Seller seller ) {
+ this.seller = seller;
+ }
+
+}
Added: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/Customer.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/Customer.java (rev 0)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/Customer.java 2010-03-01 13:23:33 UTC (rev 18910)
@@ -0,0 +1,57 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public abstract class Customer implements Serializable {
+ private PersonID id;
+
+ public PersonID getId() {
+ return id;
+ }
+
+ public void setId( PersonID id ) {
+ this.id = id;
+ }
+
+ public boolean equals( Object obj ) {
+ if ( obj == null )
+ return false;
+ if ( obj == this )
+ return true;
+ if ( !( obj instanceof Customer ) )
+ return false;
+ return ( (Customer) obj ).getId().equals( getId() );
+ }
+
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+}
Added: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/PersonID.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/PersonID.java (rev 0)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/PersonID.java 2010-03-01 13:23:33 UTC (rev 18910)
@@ -0,0 +1,94 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public class PersonID implements Serializable {
+ private Long num;
+ private String name;
+
+ public Long getNum() {
+ return num;
+ }
+
+ public void setNum( Long num ) {
+ this.num = num;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ public boolean equals( Object obj ) {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ final PersonID other = (PersonID) obj;
+ if ( name == null ) {
+ if ( other.name != null )
+ return false;
+
+ } else if ( !name.equals( other.name ) ) {
+ return false;
+ }
+ if ( num == null ) {
+ if ( other.num != null )
+ return false;
+
+ } else if ( !num.equals( other.num ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ if ( name != null ) {
+ result += name.hashCode();
+ }
+ result *= PRIME;
+ if ( num != null ) {
+ result += num.hashCode();
+ }
+ return result;
+ }
+
+ public String toString() {
+ return name + " | " + num;
+ }
+
+}
Added: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/SellCarTest.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/SellCarTest.java (rev 0)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/SellCarTest.java 2010-03-01 13:23:33 UTC (rev 18910)
@@ -0,0 +1,82 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+
+/**
+ * http://opensource.atlassian.com/projects/hibernate/browse/HHH-4825
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public class SellCarTest extends FunctionalTestCase {
+
+ public SellCarTest( String string ) {
+ super( string );
+ }
+
+ public String[] getMappings() {
+ return new String[] { "unionsubclass/alias/mapping.hbm.xml" };
+ }
+
+ public void testSellCar() throws Exception {
+ prepareData();
+ Session session = openSession();
+ Transaction tx = session.beginTransaction();
+ Query query = session.createQuery( "from Seller" );
+ Seller seller = (Seller) query.uniqueResult();
+ assertNotNull( seller );
+ assertEquals( 1, seller.getBuyers().size() );
+ tx.commit();
+ session.close();
+ }
+
+ private void prepareData() {
+ Session session = openSession();
+ Transaction tx = session.beginTransaction();
+ session.save( createData() );
+ tx.commit();
+ session.close();
+ }
+
+ private Object createData() {
+ Seller stliu = new Seller();
+ stliu.setId( createID( "stliu" ) );
+ CarBuyer zd = new CarBuyer();
+ zd.setId( createID( "zd" ) );
+ zd.setSeller( stliu );
+ zd.setSellerName( stliu.getId().getName() );
+ stliu.getBuyers().add( zd );
+ return stliu;
+ }
+
+ private PersonID createID( String name ) {
+ PersonID id = new PersonID();
+ id.setName( name );
+ id.setNum( new Long( 100 ) );
+ return id;
+ }
+}
Added: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/Seller.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/Seller.java (rev 0)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/Seller.java 2010-03-01 13:23:33 UTC (rev 18910)
@@ -0,0 +1,69 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.unionsubclass.alias;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ *
+ * @author Strong Liu <stliu(a)redhat.com>
+ */
+public class Seller implements Serializable {
+ private PersonID id;
+ private Set buyers = new HashSet();
+
+ public PersonID getId() {
+ return id;
+ }
+
+ public void setId( PersonID id ) {
+ this.id = id;
+ }
+
+ public Set getBuyers() {
+ return buyers;
+ }
+
+ public void setBuyers( Set buyers ) {
+ this.buyers = buyers;
+ }
+
+ public boolean equals( Object obj ) {
+ if ( obj == null )
+ return false;
+ if ( obj == this )
+ return true;
+ if ( !( obj instanceof Seller ) )
+ return false;
+
+ return ( (Seller) obj ).getId().equals( getId() );
+ }
+
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+}
Added: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/mapping.hbm.xml
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/mapping.hbm.xml (rev 0)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/unionsubclass/alias/mapping.hbm.xml 2010-03-01 13:23:33 UTC (rev 18910)
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping package="org.hibernate.test.unionsubclass.alias">
+
+ <class name="Seller">
+ <composite-id class="PersonID" name="id">
+ <key-property column="NR_RZBK" name="num" />
+ <key-property column="TXT_OID" name="name" />
+ </composite-id>
+ <set cascade="persist, merge, save-update" inverse="true" lazy="false"
+ name="buyers">
+ <key>
+ <column name="NR_RZBK" />
+ <column name="TXT_OID_TESTB" />
+ </key>
+ <one-to-many class="CarBuyer" />
+ </set>
+ </class>
+
+ <class abstract="true" name="Customer">
+ <composite-id class="PersonID" name="id">
+ <key-property column="NR_RZBK" name="num" />
+ <key-property column="TXT_OID" name="name" />
+ </composite-id>
+ <union-subclass name="CarBuyer">
+ <property column="PID" name="pid" update="false" />
+ <property column="TXT_OID_TESTB" name="sellerName" />
+ <many-to-one cascade="persist, merge, save-update" class="Seller"
+ insert="false" name="seller" update="false">
+ <column name="NR_RZBK" />
+ <column name="TXT_OID_TESTB" />
+ </many-to-one>
+ </union-subclass>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
14 years, 9 months
Hibernate SVN: r18909 - core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-03-01 08:11:22 -0500 (Mon, 01 Mar 2010)
New Revision: 18909
Modified:
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/AllTests.java
Log:
JBPAPP-3107 Include new test in AllTests
Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/AllTests.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/AllTests.java 2010-03-01 12:58:26 UTC (rev 18908)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/AllTests.java 2010-03-01 13:11:22 UTC (rev 18909)
@@ -136,6 +136,7 @@
import org.hibernate.test.version.db.DbVersionTest;
import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
import org.hibernate.test.where.WhereTest;
+import org.hibernate.test.manytomany.batchload.BatchedManyToManyTest;
/**
* @author Gavin King
@@ -315,6 +316,7 @@
suite.addTest( InsertOrderingTest.suite() );
suite.addTest( ReattachmentSuite.suite() );
suite.addTest( MigrationTest.suite() );
+ suite.addTest( BatchedManyToManyTest.suite() );
return suite;
}
14 years, 9 months
*** 80% OFF For hibernate-commits ***
by Brand Male Meds
Press the link to go to shop http://92.wearvery.ru/
amyhu pugy ycajyhiw cyvohavox
qaazonex uzic nyzuzoxowa aqouo
oode yogorewydy emerypij hahyjy
epuyzyb gyty uluviky yixie
exowy abyra iwykemuouk iery
ipeydop yrui ifale zelu
isexito sycyk hiqygaqeky jyqaygekyu
obyqoujyof feeviro aqyvag uusiup
ygico huuvuogadu amautaohy upacybeca
iwyherutiv zolaxyh exub oejyqid
yjahyywi higyh ufagy agium
iiqyl hohaymo egigu tineybo
ihawudyxi eicexup oyemy nocol
asehyf hadeopebe oragyure ufiekyna
lexejolauf ybypa ihod ifofix
izysoceal yjoiqiso ekorubame pyvuwenidy
udetao tysity idyfe atepe
diavivaxi ytipi ymyj omouxo
14 years, 9 months
Hibernate SVN: r18908 - entitymanager/branches/v3_3_2_GA_CP/src/test/org/hibernate/ejb/test/emops.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-03-01 07:58:26 -0500 (Mon, 01 Mar 2010)
New Revision: 18908
Modified:
entitymanager/branches/v3_3_2_GA_CP/src/test/org/hibernate/ejb/test/emops/Competition.java
Log:
JBPAPP-3071 Some tests in MergeTest fails because of "unsorted" bag
Modified: entitymanager/branches/v3_3_2_GA_CP/src/test/org/hibernate/ejb/test/emops/Competition.java
===================================================================
--- entitymanager/branches/v3_3_2_GA_CP/src/test/org/hibernate/ejb/test/emops/Competition.java 2010-03-01 12:16:27 UTC (rev 18907)
+++ entitymanager/branches/v3_3_2_GA_CP/src/test/org/hibernate/ejb/test/emops/Competition.java 2010-03-01 12:58:26 UTC (rev 18908)
@@ -1,7 +1,6 @@
//$Id: $
package org.hibernate.ejb.test.emops;
-import java.util.Collection;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
@@ -12,6 +11,7 @@
import javax.persistence.FetchType;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
+import javax.persistence.OrderBy;
/**
* @author Emmanuel Bernard
@@ -26,6 +26,7 @@
fetch = FetchType.LAZY)
@JoinTable(name="competition_competitor")
@JoinColumn
+ @OrderBy("id")
private List<Competitor> competitors = new ArrayList<Competitor>();
14 years, 9 months
Hibernate SVN: r18907 - entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-03-01 07:16:27 -0500 (Mon, 01 Mar 2010)
New Revision: 18907
Modified:
entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/Ejb3Configuration.java
Log:
license header
Modified: entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/Ejb3Configuration.java
===================================================================
--- entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/Ejb3Configuration.java 2010-03-01 00:30:48 UTC (rev 18906)
+++ entitymanager/branches/v3_3_2_GA_CP/src/java/org/hibernate/ejb/Ejb3Configuration.java 2010-03-01 12:16:27 UTC (rev 18907)
@@ -1,4 +1,28 @@
//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
package org.hibernate.ejb;
import java.io.BufferedInputStream;
14 years, 9 months
Hibernate SVN: r18906 - core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-02-28 19:30:48 -0500 (Sun, 28 Feb 2010)
New Revision: 18906
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/BytecodeProvider.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/ClassTransformer.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/ProxyFactoryFactory.java
Log:
no code change, correct typo in javadoc
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/BytecodeProvider.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/BytecodeProvider.java 2010-02-28 22:38:56 UTC (rev 18905)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/BytecodeProvider.java 2010-03-01 00:30:48 UTC (rev 18906)
@@ -9,8 +9,8 @@
* Bytecode requirements break down into basically 3 areas<ol>
* <li>proxy generation (both for runtime-lazy-loading and basic proxy generation)
* {@link #getProxyFactoryFactory()}
- * <li>bean relection optimization {@link #getReflectionOptimizer}
- * <li>field-access instumentation {@link #getTransformer}
+ * <li>bean reflection optimization {@link #getReflectionOptimizer}
+ * <li>field-access instrumentation {@link #getTransformer}
* </ol>
*
* @author Steve Ebersole
@@ -20,7 +20,7 @@
* Retrieve the specific factory for this provider capable of
* generating run-time proxies for lazy-loading purposes.
*
- * @return The provider specifc factory.
+ * @return The provider specific factory.
*/
public ProxyFactoryFactory getProxyFactoryFactory();
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/ClassTransformer.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/ClassTransformer.java 2010-02-28 22:38:56 UTC (rev 18905)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/ClassTransformer.java 2010-03-01 00:30:48 UTC (rev 18906)
@@ -19,7 +19,7 @@
/**
* Invoked when a class is being loaded or redefined to add hooks for persistence bytecode manipulation
*
- * @param loader the defining class loaderof the class being transformed. It may be null if using bootstrap loader
+ * @param loader the defining class loader of the class being transformed. It may be null if using bootstrap loader
* @param classname The name of the class being transformed
* @param classBeingRedefined If an already loaded class is being redefined, then pass this as a parameter
* @param protectionDomain ProtectionDomain of the class being (re)-defined
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/ProxyFactoryFactory.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/ProxyFactoryFactory.java 2010-02-28 22:38:56 UTC (rev 18905)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/bytecode/ProxyFactoryFactory.java 2010-03-01 00:30:48 UTC (rev 18906)
@@ -5,7 +5,7 @@
/**
* An interface for factories of {@link ProxyFactory proxy factory} instances.
* <p/>
- * Currently used to abstract from the tupizer whether we are using CGLIB or
+ * Currently used to abstract from the tuplizer whether we are using CGLIB or
* Javassist for lazy proxy generation.
*
* @author Steve Ebersole
14 years, 9 months