HHH-4993 : Updates to read-only entity associations made while in persistent state are ignored by flush (tests only)
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18957 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
3153fb385d
commit
e801874604
|
@ -11,6 +11,7 @@ import java.util.Set;
|
|||
public class Contract implements Serializable {
|
||||
|
||||
private long id;
|
||||
private long version;
|
||||
private String customerName;
|
||||
private String type;
|
||||
private List variations;
|
||||
|
@ -26,8 +27,8 @@ public class Contract implements Serializable {
|
|||
|
||||
public Contract(Plan plan, String customerName, String type) {
|
||||
plans = new HashSet();
|
||||
plans.add( plan );
|
||||
if ( plan != null ) {
|
||||
plans.add( plan );
|
||||
plan.getContracts().add( this );
|
||||
}
|
||||
this.customerName = customerName;
|
||||
|
@ -38,6 +39,14 @@ public class Contract implements Serializable {
|
|||
infos = new HashSet();
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Set getPlans() {
|
||||
return plans;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<generator class="increment"/>
|
||||
</id>
|
||||
<!-- <many-to-one name="contract" update="false" insert="false"/> -->
|
||||
<many-to-one name="contract" not-null="true"/>
|
||||
<many-to-one name="contract" not-null="false"/>
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
|
@ -85,7 +85,7 @@
|
|||
<property name="text" type="text"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key>
|
||||
<column name="contract"/>
|
||||
<column name="contractvariation"/>
|
||||
<column name="version"/>
|
||||
</key>
|
||||
<one-to-many class="Info"/>
|
||||
|
|
|
@ -1222,6 +1222,234 @@ public class ImmutableTest extends FunctionalTestCase {
|
|||
assertDeleteCount( 4 );
|
||||
}
|
||||
|
||||
public void testImmutableEntityAddImmutableToInverseMutableCollection() {
|
||||
clearCounts();
|
||||
|
||||
Contract c = new Contract( null, "gavin", "phone");
|
||||
ContractVariation cv1 = new ContractVariation(1, c);
|
||||
cv1.setText("expensive");
|
||||
ContractVariation cv2 = new ContractVariation(2, c);
|
||||
cv2.setText("more expensive");
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
s.persist(c);
|
||||
Party party = new Party( "a party" );
|
||||
s.persist( party );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertInsertCount( 4 );
|
||||
assertUpdateCount( 0 );
|
||||
clearCounts();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
c.addParty( new Party( "a new party" ) );
|
||||
s.update( c );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertInsertCount( 1 );
|
||||
assertUpdateCount( 0 );
|
||||
clearCounts();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
c.addParty( party );
|
||||
s.update( c );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
c = (Contract) s.createCriteria(Contract.class).uniqueResult();
|
||||
assertEquals( c.getCustomerName(), "gavin" );
|
||||
assertEquals( c.getVariations().size(), 2 );
|
||||
Iterator it = c.getVariations().iterator();
|
||||
cv1 = (ContractVariation) it.next();
|
||||
assertEquals( cv1.getText(), "expensive" );
|
||||
cv2 = (ContractVariation) it.next();
|
||||
assertEquals( cv2.getText(), "more expensive" );
|
||||
//assertEquals( 2, c.getParties().size() );
|
||||
s.delete(c);
|
||||
assertEquals( s.createCriteria(Contract.class).setProjection( Projections.rowCount() ).uniqueResult(), new Long(0) );
|
||||
assertEquals( s.createCriteria(ContractVariation.class).setProjection( Projections.rowCount() ).uniqueResult(), new Long(0) );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertDeleteCount( 4 );
|
||||
}
|
||||
|
||||
public void testImmutableEntityRemoveImmutableFromInverseMutableCollection() {
|
||||
clearCounts();
|
||||
|
||||
Contract c = new Contract( null, "gavin", "phone");
|
||||
ContractVariation cv1 = new ContractVariation(1, c);
|
||||
cv1.setText("expensive");
|
||||
ContractVariation cv2 = new ContractVariation(2, c);
|
||||
cv2.setText("more expensive");
|
||||
Party party = new Party( "party1" );
|
||||
c.addParty( party );
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
s.persist(c);
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertInsertCount( 4 );
|
||||
assertUpdateCount( 0 );
|
||||
clearCounts();
|
||||
|
||||
party = ( Party ) c.getParties().iterator().next();
|
||||
c.removeParty( party );
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
s.update( c );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
clearCounts();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
c = (Contract) s.createCriteria(Contract.class).uniqueResult();
|
||||
assertEquals( c.getCustomerName(), "gavin" );
|
||||
assertEquals( c.getVariations().size(), 2 );
|
||||
Iterator it = c.getVariations().iterator();
|
||||
cv1 = (ContractVariation) it.next();
|
||||
assertEquals( cv1.getText(), "expensive" );
|
||||
cv2 = (ContractVariation) it.next();
|
||||
assertEquals( cv2.getText(), "more expensive" );
|
||||
//assertEquals( 0, c.getParties().size() );
|
||||
s.delete(c);
|
||||
assertEquals( s.createCriteria(Contract.class).setProjection( Projections.rowCount() ).uniqueResult(), new Long(0) );
|
||||
assertEquals( s.createCriteria(ContractVariation.class).setProjection( Projections.rowCount() ).uniqueResult(), new Long(0) );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertDeleteCount( 4 );
|
||||
}
|
||||
|
||||
public void testImmutableEntityRemoveImmutableFromInverseMutableCollectionByDelete() {
|
||||
clearCounts();
|
||||
|
||||
Contract c = new Contract( null, "gavin", "phone");
|
||||
ContractVariation cv1 = new ContractVariation(1, c);
|
||||
cv1.setText("expensive");
|
||||
ContractVariation cv2 = new ContractVariation(2, c);
|
||||
cv2.setText("more expensive");
|
||||
Party party = new Party( "party1" );
|
||||
c.addParty( party );
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
s.persist(c);
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertInsertCount( 4 );
|
||||
assertUpdateCount( 0 );
|
||||
clearCounts();
|
||||
|
||||
party = ( Party ) c.getParties().iterator().next();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
s.delete( party );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertDeleteCount( 1 );
|
||||
clearCounts();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
c = (Contract) s.createCriteria(Contract.class).uniqueResult();
|
||||
assertEquals( c.getCustomerName(), "gavin" );
|
||||
assertEquals( c.getVariations().size(), 2 );
|
||||
Iterator it = c.getVariations().iterator();
|
||||
cv1 = (ContractVariation) it.next();
|
||||
assertEquals( cv1.getText(), "expensive" );
|
||||
cv2 = (ContractVariation) it.next();
|
||||
assertEquals( cv2.getText(), "more expensive" );
|
||||
assertEquals( 0, c.getParties().size() );
|
||||
s.delete(c);
|
||||
assertEquals( s.createCriteria(Contract.class).setProjection( Projections.rowCount() ).uniqueResult(), new Long(0) );
|
||||
assertEquals( s.createCriteria(ContractVariation.class).setProjection( Projections.rowCount() ).uniqueResult(), new Long(0) );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertDeleteCount( 3 );
|
||||
}
|
||||
|
||||
public void testImmutableEntityRemoveImmutableFromInverseMutableCollectionByDeref() {
|
||||
clearCounts();
|
||||
|
||||
Contract c = new Contract( null, "gavin", "phone");
|
||||
ContractVariation cv1 = new ContractVariation(1, c);
|
||||
cv1.setText("expensive");
|
||||
ContractVariation cv2 = new ContractVariation(2, c);
|
||||
cv2.setText("more expensive");
|
||||
Party party = new Party( "party1" );
|
||||
c.addParty( party );
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
s.persist(c);
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertInsertCount( 4 );
|
||||
assertUpdateCount( 0 );
|
||||
clearCounts();
|
||||
|
||||
party = ( Party ) c.getParties().iterator().next();
|
||||
party.setContract( null );
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
s.update( party );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
party = ( Party ) s.get( Party.class, party.getId() );
|
||||
assertNotNull( party.getContract() );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
clearCounts();
|
||||
|
||||
s = openSession();
|
||||
t = s.beginTransaction();
|
||||
c = (Contract) s.createCriteria(Contract.class).uniqueResult();
|
||||
assertEquals( c.getCustomerName(), "gavin" );
|
||||
assertEquals( c.getVariations().size(), 2 );
|
||||
Iterator it = c.getVariations().iterator();
|
||||
cv1 = (ContractVariation) it.next();
|
||||
assertEquals( cv1.getText(), "expensive" );
|
||||
cv2 = (ContractVariation) it.next();
|
||||
assertEquals( cv2.getText(), "more expensive" );
|
||||
assertEquals( 1, c.getParties().size() );
|
||||
party = ( Party ) c.getParties().iterator().next();
|
||||
assertEquals( "party1", party.getName() );
|
||||
assertSame( c, party.getContract() );
|
||||
s.delete(c);
|
||||
assertEquals( s.createCriteria(Contract.class).setProjection( Projections.rowCount() ).uniqueResult(), new Long(0) );
|
||||
assertEquals( s.createCriteria(ContractVariation.class).setProjection( Projections.rowCount() ).uniqueResult(), new Long(0) );
|
||||
t.commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertDeleteCount( 4 );
|
||||
}
|
||||
|
||||
protected void clearCounts() {
|
||||
getSessions().getStatistics().clear();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ public class Info implements Serializable {
|
|||
|
||||
private long id;
|
||||
private String text;
|
||||
private long version;
|
||||
|
||||
public Info() {
|
||||
super();
|
||||
|
@ -16,6 +17,14 @@ public class Info implements Serializable {
|
|||
this.text = text;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Set;
|
|||
public class Party implements Serializable {
|
||||
|
||||
private long id;
|
||||
private long version;
|
||||
private Contract contract;
|
||||
private String name;
|
||||
private Set infos = new HashSet();
|
||||
|
@ -22,6 +23,14 @@ public class Party implements Serializable {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||
public class Plan implements Serializable {
|
||||
|
||||
private long id;
|
||||
private long version;
|
||||
private String description;
|
||||
private Set contracts;
|
||||
private Set infos;
|
||||
|
@ -23,6 +24,14 @@ public class Plan implements Serializable {
|
|||
infos = new HashSet();
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Contract implements Serializable {
|
||||
|
||||
private long id;
|
||||
private long version;
|
||||
private String customerName;
|
||||
private String type;
|
||||
private List variations;
|
||||
private Contract parent;
|
||||
private Set subcontracts;
|
||||
private Set plans = new HashSet();
|
||||
private Set parties;
|
||||
private Set infos;
|
||||
|
||||
public Contract() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Contract(Plan plan, String customerName, String type) {
|
||||
plans = new HashSet();
|
||||
if ( plan != null ) {
|
||||
plans.add( plan );
|
||||
plan.getContracts().add( this );
|
||||
}
|
||||
this.customerName = customerName;
|
||||
this.type = type;
|
||||
variations = new ArrayList();
|
||||
subcontracts = new HashSet();
|
||||
parties = new HashSet();
|
||||
infos = new HashSet();
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Set getPlans() {
|
||||
return plans;
|
||||
}
|
||||
|
||||
public void setPlans(Set plans) {
|
||||
this.plans = plans;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List getVariations() {
|
||||
return variations;
|
||||
}
|
||||
|
||||
public void setVariations(List variations) {
|
||||
this.variations = variations;
|
||||
}
|
||||
|
||||
public Contract getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(Contract parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Set getSubcontracts() {
|
||||
return subcontracts;
|
||||
}
|
||||
|
||||
public void setSubcontracts(Set subcontracts) {
|
||||
this.subcontracts = subcontracts;
|
||||
}
|
||||
|
||||
public void addSubcontract(Contract subcontract) {
|
||||
subcontracts.add( subcontract );
|
||||
subcontract.setParent( this );
|
||||
}
|
||||
|
||||
public Set getParties() {
|
||||
return parties;
|
||||
}
|
||||
|
||||
public void setParties(Set parties) {
|
||||
this.parties = parties;
|
||||
}
|
||||
|
||||
public void addParty(Party party) {
|
||||
parties.add( party );
|
||||
party.setContract( this );
|
||||
}
|
||||
|
||||
public void removeParty(Party party) {
|
||||
parties.remove( party );
|
||||
party.setContract( null );
|
||||
}
|
||||
|
||||
public Set getInfos() {
|
||||
return infos;
|
||||
}
|
||||
|
||||
public void setInfos(Set infos) {
|
||||
this.infos = infos;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ContractVariation implements Serializable {
|
||||
|
||||
private int id;
|
||||
private Contract contract;
|
||||
private String text;
|
||||
private Set infos = new HashSet();
|
||||
|
||||
public Contract getContract() {
|
||||
return contract;
|
||||
}
|
||||
|
||||
public void setContract(Contract contract) {
|
||||
this.contract = contract;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public ContractVariation() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ContractVariation(int version, Contract contract) {
|
||||
this.contract = contract;
|
||||
this.id = id;
|
||||
contract.getVariations().add(this);
|
||||
}
|
||||
|
||||
public Set getInfos() {
|
||||
return infos;
|
||||
}
|
||||
|
||||
public void setInfos(Set infos) {
|
||||
this.infos = infos;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Info implements Serializable {
|
||||
|
||||
private long id;
|
||||
private String text;
|
||||
private long version;
|
||||
|
||||
public Info() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Info(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Owner implements Serializable {
|
||||
|
||||
private long id;
|
||||
private long version;
|
||||
private Plan plan;
|
||||
private String name;
|
||||
|
||||
public Owner() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Owner(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Plan getPlan() {
|
||||
return plan;
|
||||
}
|
||||
|
||||
public void setPlan(Plan plan) {
|
||||
this.plan = plan;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Party implements Serializable {
|
||||
|
||||
private long id;
|
||||
private long version;
|
||||
private Contract contract;
|
||||
private String name;
|
||||
private Set infos = new HashSet();
|
||||
|
||||
public Party() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Party(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Contract getContract() {
|
||||
return contract;
|
||||
}
|
||||
|
||||
public void setContract(Contract contract) {
|
||||
this.contract = contract;
|
||||
}
|
||||
|
||||
public Set getInfos() {
|
||||
return infos;
|
||||
}
|
||||
|
||||
public void setInfos(Set infos) {
|
||||
this.infos = infos;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
public class Plan implements Serializable {
|
||||
|
||||
private long id;
|
||||
private long version;
|
||||
private String description;
|
||||
private Set contracts;
|
||||
private Set infos;
|
||||
private Owner owner;
|
||||
|
||||
public Plan() {
|
||||
this( null );
|
||||
}
|
||||
|
||||
public Plan(String description) {
|
||||
this.description = description;
|
||||
contracts = new HashSet();
|
||||
infos = new HashSet();
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Set getContracts() {
|
||||
return contracts;
|
||||
}
|
||||
|
||||
public void setContracts(Set contracts) {
|
||||
this.contracts = contracts;
|
||||
}
|
||||
|
||||
public void addContract(Contract contract) {
|
||||
if ( ! contracts.add( contract ) ) {
|
||||
return;
|
||||
}
|
||||
if ( contract.getParent() != null ) {
|
||||
addContract( contract.getParent() );
|
||||
}
|
||||
contract.getPlans().add( this );
|
||||
for ( Iterator it=contract.getSubcontracts().iterator(); it.hasNext(); ) {
|
||||
Contract sub = ( Contract ) it.next();
|
||||
addContract( sub );
|
||||
}
|
||||
}
|
||||
|
||||
public void removeContract(Contract contract) {
|
||||
if ( contract.getParent() != null ) {
|
||||
contract.getParent().getSubcontracts().remove( contract );
|
||||
contract.setParent( null );
|
||||
}
|
||||
removeSubcontracts( contract );
|
||||
contract.getPlans().remove( this );
|
||||
contracts.remove( contract );
|
||||
}
|
||||
|
||||
public void removeSubcontracts(Contract contract) {
|
||||
for ( Iterator it=contract.getSubcontracts().iterator(); it.hasNext(); ) {
|
||||
Contract sub = ( Contract ) it.next();
|
||||
removeSubcontracts( sub );
|
||||
sub.getPlans().remove( this );
|
||||
contracts.remove( sub );
|
||||
}
|
||||
}
|
||||
|
||||
public Set getInfos() {
|
||||
return infos;
|
||||
}
|
||||
|
||||
public void setInfos(Set infos) {
|
||||
this.infos = infos;
|
||||
}
|
||||
|
||||
public Owner getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(Owner owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Test for immutable classes/collections.
|
||||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.immutable.entitywithmutablecollection">
|
||||
<class name="Info" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text"/>
|
||||
</class>
|
||||
|
||||
<class name="Plan" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="description" not-null="true"/>
|
||||
<set name="contracts" table="plan_contract" inverse="true" mutable="true" cascade="all" fetch="join">
|
||||
<key column="plan"/>
|
||||
<many-to-many column="contract" class="Contract"/>
|
||||
</set>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="plan"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Party" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<many-to-one name="contract" not-null="false"/>
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Contract" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<bag name="variations" inverse="true" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="ContractVariation"/>
|
||||
</bag>
|
||||
<many-to-one name="parent" />
|
||||
<set name="subcontracts" inverse="true"
|
||||
mutable="true" cascade="all" fetch="join">
|
||||
<key column="parent"/>
|
||||
<one-to-many class="Contract"/>
|
||||
</set>
|
||||
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="plan" class="Plan"/>
|
||||
</set>
|
||||
<set name="parties" inverse="true" mutable="true" cascade="all" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Party"/>
|
||||
</set>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="ContractVariation" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text" type="text"/>
|
||||
<many-to-one name="contract" not-null="false"/>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contractvariation"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Test for immutable classes/collections.
|
||||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.immutable.entitywithmutablecollection">
|
||||
<class name="Info" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text"/>
|
||||
</class>
|
||||
|
||||
<class name="Plan" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="description" not-null="true"/>
|
||||
<set name="contracts" table="plan_contract" inverse="true" mutable="true" cascade="all" fetch="join">
|
||||
<key column="plan"/>
|
||||
<many-to-many column="contract" class="Contract"/>
|
||||
</set>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="plan"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Party" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
<join table="contract_party"
|
||||
inverse="false"
|
||||
optional="true">
|
||||
<key column="party"/>
|
||||
<many-to-one name="contract"
|
||||
column="contract"
|
||||
not-null="true"/>
|
||||
</join>
|
||||
</class>
|
||||
|
||||
<class name="Contract" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<bag name="variations" inverse="true" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="ContractVariation"/>
|
||||
</bag>
|
||||
<many-to-one name="parent" />
|
||||
<set name="subcontracts" inverse="true"
|
||||
mutable="true" cascade="all" fetch="join">
|
||||
<key column="parent"/>
|
||||
<one-to-many class="Contract"/>
|
||||
</set>
|
||||
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="plan" class="Plan"/>
|
||||
</set>
|
||||
<set name="parties" table="contract_party" inverse="true" mutable="true" cascade="all">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="party" unique="true" class="Party"/>
|
||||
</set>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="ContractVariation" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text" type="text"/>
|
||||
<many-to-one name="contract" not-null="false"/>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contractvariation"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Test for readonly.entitywithmutablecollection classes/collections.
|
||||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.immutable.entitywithmutablecollection">
|
||||
<class name="Info" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="text"/>
|
||||
</class>
|
||||
|
||||
<class name="Plan" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="description" not-null="true"/>
|
||||
<set name="contracts" table="plan_contract" inverse="true" mutable="true" cascade="all" fetch="join">
|
||||
<key column="plan"/>
|
||||
<many-to-many column="contract" class="Contract"/>
|
||||
</set>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="plan"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Party" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<many-to-one name="contract" not-null="false"/>
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Contract" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<bag name="variations" inverse="true" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="ContractVariation"/>
|
||||
</bag>
|
||||
<many-to-one name="parent" />
|
||||
<set name="subcontracts" inverse="true"
|
||||
mutable="true" cascade="all" fetch="join">
|
||||
<key column="parent"/>
|
||||
<one-to-many class="Contract"/>
|
||||
</set>
|
||||
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="plan" class="Plan"/>
|
||||
</set>
|
||||
<set name="parties" inverse="true" mutable="true" cascade="all" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Party"/>
|
||||
</set>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="ContractVariation" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text" type="text"/>
|
||||
<many-to-one name="contract" not-null="false"/>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contractvariation"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Test for readonly.entitywithmutablecollection classes/collections.
|
||||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.immutable.entitywithmutablecollection">
|
||||
<class name="Info" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="text"/>
|
||||
</class>
|
||||
|
||||
<class name="Plan" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="description" not-null="true"/>
|
||||
<set name="contracts" table="plan_contract" inverse="true" mutable="true" cascade="all" fetch="join">
|
||||
<key column="plan"/>
|
||||
<many-to-many column="contract" class="Contract"/>
|
||||
</set>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="plan"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Party" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
<join table="contract_party"
|
||||
inverse="false"
|
||||
optional="true">
|
||||
<key column="party"/>
|
||||
<many-to-one name="contract"
|
||||
column="contract"
|
||||
not-null="true"/>
|
||||
</join>
|
||||
</class>
|
||||
|
||||
<class name="Contract" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<bag name="variations" inverse="true" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="ContractVariation"/>
|
||||
</bag>
|
||||
<many-to-one name="parent" />
|
||||
<set name="subcontracts" inverse="true"
|
||||
mutable="true" cascade="all" fetch="join">
|
||||
<key column="parent"/>
|
||||
<one-to-many class="Contract"/>
|
||||
</set>
|
||||
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="plan" class="Plan"/>
|
||||
</set>
|
||||
<set name="parties" table="contract_party" inverse="true" mutable="true" cascade="all">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="party" unique="true" class="Party"/>
|
||||
</set>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="ContractVariation" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text" type="text"/>
|
||||
<many-to-one name="contract" not-null="false"/>
|
||||
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contractvariation"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.inverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityWithInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
|
||||
|
||||
public EntityWithInverseManyToManyTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( EntityWithInverseManyToManyTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.inverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityWithInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public EntityWithInverseOneToManyJoinTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( EntityWithInverseOneToManyJoinTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.inverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityWithInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public EntityWithInverseOneToManyTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( EntityWithInverseOneToManyTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.inverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class VersionedEntityWithInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
|
||||
|
||||
public VersionedEntityWithInverseManyToManyTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( VersionedEntityWithInverseManyToManyTest.class );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.inverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*
|
||||
* These tests reproduce HHH-4992.
|
||||
*/
|
||||
public class VersionedEntityWithInverseOneToManyFailureExpectedTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public VersionedEntityWithInverseOneToManyFailureExpectedTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( VersionedEntityWithInverseOneToManyFailureExpectedTest.class );
|
||||
}
|
||||
|
||||
public void testAddExistingOneToManyElementToPersistentEntity() {
|
||||
reportSkip(
|
||||
"known to fail with versioned entity with inverse collection",
|
||||
"AddExistingOneToManyElementToPersistentEntity"
|
||||
);
|
||||
}
|
||||
|
||||
public void testAddExistingOneToManyElementToPersistentEntityFailureExpected() {
|
||||
super.testAddExistingOneToManyElementToPersistentEntity();
|
||||
}
|
||||
|
||||
public void testCreateWithEmptyOneToManyCollectionUpdateWithExistingElement() {
|
||||
reportSkip(
|
||||
"known to fail with versioned entity with inverse collection",
|
||||
"CreateWithEmptyOneToManyCollectionUpdateWithExistingElement"
|
||||
);
|
||||
}
|
||||
|
||||
public void testCreateWithEmptyOneToManyCollectionUpdateWithExistingElementFailureExpected() {
|
||||
super.testCreateWithEmptyOneToManyCollectionUpdateWithExistingElement();
|
||||
}
|
||||
|
||||
public void testCreateWithEmptyOneToManyCollectionMergeWithExistingElement() {
|
||||
reportSkip(
|
||||
"known to fail with versioned entity with inverse collection",
|
||||
"CreateWithEmptyOneToManyCollectionMergeWithExistingElement"
|
||||
);
|
||||
}
|
||||
|
||||
public void testCreateWithEmptyOneToManyCollectionMergeWithExistingElementFailureExpected() {
|
||||
super.testCreateWithEmptyOneToManyCollectionMergeWithExistingElement();
|
||||
}
|
||||
|
||||
public void testRemoveOneToManyElementUsingUpdate() {
|
||||
reportSkip(
|
||||
"known to fail with versioned entity with inverse collection",
|
||||
"RemoveOneToManyElementUsingUpdate"
|
||||
);
|
||||
}
|
||||
|
||||
public void testRemoveOneToManyElementUsingUpdateFailureExpected() {
|
||||
super.testRemoveOneToManyElementUsingUpdate();
|
||||
}
|
||||
|
||||
public void testRemoveOneToManyElementUsingMerge() {
|
||||
reportSkip(
|
||||
"known to fail with versioned entity with inverse collection",
|
||||
"RemoveOneToManyElementUsingMerge"
|
||||
);
|
||||
}
|
||||
|
||||
public void testRemoveOneToManyElementUsingMergeFailureExpected() {
|
||||
super.testRemoveOneToManyElementUsingMerge();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.inverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class VersionedEntityWithInverseOneToManyJoinFailureExpectedTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public VersionedEntityWithInverseOneToManyJoinFailureExpectedTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( VersionedEntityWithInverseOneToManyJoinFailureExpectedTest.class );
|
||||
}
|
||||
|
||||
public void testAddExistingOneToManyElementToPersistentEntity() {
|
||||
reportSkip(
|
||||
"known to fail with inverse collection",
|
||||
"AddExistingOneToManyElementToPersistentEntity"
|
||||
);
|
||||
}
|
||||
|
||||
public void testAddExistingOneToManyElementToPersistentEntityFailureExpected() {
|
||||
super.testAddExistingOneToManyElementToPersistentEntity();
|
||||
}
|
||||
|
||||
public void testCreateWithEmptyOneToManyCollectionUpdateWithExistingElement() {
|
||||
reportSkip(
|
||||
"known to fail with inverse collection",
|
||||
"CreateWithEmptyOneToManyCollectionUpdateWithExistingElement"
|
||||
);
|
||||
}
|
||||
|
||||
public void testCreateWithEmptyOneToManyCollectionUpdateWithExistingElementFailureExpected() {
|
||||
super.testCreateWithEmptyOneToManyCollectionUpdateWithExistingElement();
|
||||
}
|
||||
|
||||
public void testCreateWithEmptyOneToManyCollectionMergeWithExistingElement() {
|
||||
reportSkip(
|
||||
"known to fail with versioned entity with inverse one-to-many collection",
|
||||
"CreateWithEmptyOneToManyCollectionMergeWithExistingElement"
|
||||
);
|
||||
}
|
||||
|
||||
public void testCreateWithEmptyOneToManyCollectionMergeWithExistingElementFailureExpected() {
|
||||
super.testCreateWithEmptyOneToManyCollectionMergeWithExistingElement();
|
||||
}
|
||||
|
||||
public void testRemoveOneToManyElementUsingUpdate() {
|
||||
reportSkip(
|
||||
"known to fail with versioned entity with inverse collection",
|
||||
"RemoveOneToManyElementUsingUpdate"
|
||||
);
|
||||
}
|
||||
|
||||
public void testRemoveOneToManyElementUsingUpdateFailureExpected() {
|
||||
super.testRemoveOneToManyElementUsingUpdate();
|
||||
}
|
||||
|
||||
public void testRemoveOneToManyElementUsingMerge() {
|
||||
reportSkip(
|
||||
"known to fail with versioned entity with inverse collection",
|
||||
"RemoveOneToManyElementUsingMerge"
|
||||
);
|
||||
}
|
||||
|
||||
public void testRemoveOneToManyElementUsingMergeFailureExpected() {
|
||||
super.testRemoveOneToManyElementUsingMerge();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.inverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*
|
||||
* These tests reproduce HHH-4992.
|
||||
*/
|
||||
public class VersionedEntityWithInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public VersionedEntityWithInverseOneToManyJoinTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml" };
|
||||
}
|
||||
|
||||
protected boolean checkUpdateCountsAfterAddingExistingElement() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean checkUpdateCountsAfterRemovingElementWithoutDelete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( VersionedEntityWithInverseOneToManyJoinTest.class );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.inverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class VersionedEntityWithInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public VersionedEntityWithInverseOneToManyTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml" };
|
||||
}
|
||||
|
||||
protected boolean checkUpdateCountsAfterAddingExistingElement() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean checkUpdateCountsAfterRemovingElementWithoutDelete() {
|
||||
return false;
|
||||
}
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( VersionedEntityWithInverseOneToManyTest.class );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Test for immutable classes/collections.
|
||||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.immutable.entitywithmutablecollection">
|
||||
<class name="Info" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text"/>
|
||||
</class>
|
||||
|
||||
<class name="Plan" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="description" not-null="true"/>
|
||||
<set name="contracts" table="plan_contract" inverse="false" mutable="true" cascade="all" fetch="join">
|
||||
<key column="plan"/>
|
||||
<many-to-many column="contract" class="Contract"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="plan"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Party" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<many-to-one name="contract" update="false" insert="false" not-null="false"/>
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Contract" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="ContractVariation"/>
|
||||
</bag>
|
||||
<many-to-one name="parent" update="false" insert="false"/>
|
||||
<set name="subcontracts" inverse="false"
|
||||
mutable="true" cascade="all" fetch="join">
|
||||
<key column="parent"/>
|
||||
<one-to-many class="Contract"/>
|
||||
</set>
|
||||
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="plan" class="Plan"/>
|
||||
</set>
|
||||
<set name="parties" inverse="false" mutable="true" cascade="all" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Party"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="ContractVariation" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text" type="text"/>
|
||||
<many-to-one name="contract" insert="false" update="false" not-null="false"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contractvariation"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Test for immutable classes/collections.
|
||||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.immutable.entitywithmutablecollection">
|
||||
<class name="Info" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text"/>
|
||||
</class>
|
||||
|
||||
<class name="Plan" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="description" not-null="true"/>
|
||||
<set name="contracts" table="plan_contract" inverse="false" mutable="true" cascade="all" fetch="join">
|
||||
<key column="plan"/>
|
||||
<many-to-many column="contract" class="Contract"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="plan"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Party" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
<join table="contract_party"
|
||||
inverse="true"
|
||||
optional="true">
|
||||
<key column="party"/>
|
||||
<many-to-one name="contract"
|
||||
column="contract"
|
||||
not-null="true"/>
|
||||
</join>
|
||||
</class>
|
||||
|
||||
<class name="Contract" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="ContractVariation"/>
|
||||
</bag>
|
||||
<many-to-one name="parent" update="false" insert="false"/>
|
||||
<set name="subcontracts" inverse="false"
|
||||
mutable="true" cascade="all" fetch="join">
|
||||
<key column="parent"/>
|
||||
<one-to-many class="Contract"/>
|
||||
</set>
|
||||
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="plan" class="Plan"/>
|
||||
</set>
|
||||
<set name="parties" table="contract_party" inverse="false" mutable="true" cascade="all">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="party" unique="true" class="Party"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="ContractVariation" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text" type="text"/>
|
||||
<many-to-one name="contract" insert="false" update="false" not-null="false"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contractvariation"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Test for immutable classes/collections.
|
||||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.immutable.entitywithmutablecollection">
|
||||
<class name="Info" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text"/>
|
||||
</class>
|
||||
|
||||
<class name="Plan" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="description" not-null="true"/>
|
||||
<set name="contracts" table="plan_contract" inverse="false" mutable="true" cascade="all" fetch="join">
|
||||
<key column="plan"/>
|
||||
<many-to-many column="contract" class="Contract"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="plan"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Party" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Contract" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="ContractVariation"/>
|
||||
</bag>
|
||||
<many-to-one name="parent" update="false" insert="false"/>
|
||||
<set name="subcontracts" inverse="false"
|
||||
mutable="true" cascade="all" fetch="join">
|
||||
<key column="parent"/>
|
||||
<one-to-many class="Contract"/>
|
||||
</set>
|
||||
<set name="parties" inverse="false" mutable="true" cascade="all" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Party"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="ContractVariation" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text" type="text"/>
|
||||
<many-to-one name="contract" insert="false" update="false" not-null="false"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contractvariation"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Test for immutable classes/collections.
|
||||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.immutable.entitywithmutablecollection">
|
||||
<class name="Info" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="text"/>
|
||||
</class>
|
||||
|
||||
<class name="Plan" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="description" not-null="true"/>
|
||||
<set name="contracts" table="plan_contract" inverse="false" mutable="true" cascade="all" fetch="join">
|
||||
<key column="plan"/>
|
||||
<many-to-many column="contract" class="Contract"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="plan"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Party" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<many-to-one name="contract" update="false" insert="false" not-null="false"/>
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Contract" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="ContractVariation"/>
|
||||
</bag>
|
||||
<many-to-one name="parent" update="false" insert="false"/>
|
||||
<set name="subcontracts" inverse="false"
|
||||
mutable="true" cascade="all" fetch="join">
|
||||
<key column="parent"/>
|
||||
<one-to-many class="Contract"/>
|
||||
</set>
|
||||
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="plan" class="Plan"/>
|
||||
</set>
|
||||
<set name="parties" inverse="false" mutable="true" cascade="all" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Party"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="ContractVariation" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text" type="text"/>
|
||||
<many-to-one name="contract" insert="false" update="false" not-null="false"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contractvariation"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
Test for immutable classes/collections.
|
||||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.immutable.entitywithmutablecollection">
|
||||
<class name="Info" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="text"/>
|
||||
</class>
|
||||
|
||||
<class name="Plan" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="description" not-null="true"/>
|
||||
<set name="contracts" table="plan_contract" inverse="false" mutable="true" cascade="all" fetch="join">
|
||||
<key column="plan"/>
|
||||
<many-to-many column="contract" class="Contract"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="plan"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Party" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="name" not-null="true"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="party"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
<join table="contract_party"
|
||||
inverse="true"
|
||||
optional="true">
|
||||
<key column="party"/>
|
||||
<many-to-one name="contract"
|
||||
column="contract"
|
||||
not-null="true"/>
|
||||
</join>
|
||||
</class>
|
||||
|
||||
<class name="Contract" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="ContractVariation"/>
|
||||
</bag>
|
||||
<many-to-one name="parent" update="false" insert="false"/>
|
||||
<set name="subcontracts" inverse="false"
|
||||
mutable="true" cascade="all" fetch="join">
|
||||
<key column="parent"/>
|
||||
<one-to-many class="Contract"/>
|
||||
</set>
|
||||
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="plan" class="Plan"/>
|
||||
</set>
|
||||
<set name="parties" table="contract_party" inverse="false" mutable="true" cascade="all">
|
||||
<key column="contract"/>
|
||||
<many-to-many column="party" unique="true" class="Party"/>
|
||||
</set>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contract"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="ContractVariation" mutable="false">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="text" type="text"/>
|
||||
<many-to-one name="contract" insert="false" update="false" not-null="false"/>
|
||||
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
|
||||
<key column="contractvariation"/>
|
||||
<one-to-many class="Info"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.noninverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
|
||||
|
||||
public EntityWithNonInverseManyToManyTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( EntityWithNonInverseManyToManyTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.noninverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityWithNonInverseManyToManyUnidirTest extends AbstractEntityWithManyToManyTest {
|
||||
|
||||
public EntityWithNonInverseManyToManyUnidirTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( EntityWithNonInverseManyToManyUnidirTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.noninverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityWithNonInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public EntityWithNonInverseOneToManyJoinTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( EntityWithNonInverseOneToManyJoinTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.noninverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public EntityWithNonInverseOneToManyTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( EntityWithNonInverseOneToManyTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.noninverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityWithNonInverseOneToManyUnidirTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public EntityWithNonInverseOneToManyUnidirTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( EntityWithNonInverseOneToManyUnidirTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.noninverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class VersionedEntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
|
||||
|
||||
public VersionedEntityWithNonInverseManyToManyTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( VersionedEntityWithNonInverseManyToManyTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.noninverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class VersionedEntityWithNonInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public VersionedEntityWithNonInverseOneToManyJoinTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( VersionedEntityWithNonInverseOneToManyJoinTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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.immutable.entitywithmutablecollection.noninverse;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
|
||||
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class VersionedEntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
|
||||
|
||||
public VersionedEntityWithNonInverseOneToManyTest(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml" };
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( VersionedEntityWithNonInverseOneToManyTest.class );
|
||||
}
|
||||
|
||||
}
|
|
@ -283,17 +283,17 @@ public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
|
|||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertInsertCount( 0 );
|
||||
assertUpdateCount( 1 );
|
||||
assertInsertCount( 1 );
|
||||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
parent = ( VersionedNode ) s.get( VersionedNode.class, parent.getId() );
|
||||
assertEquals( "parent", parent.getName() );
|
||||
assertEquals( 0, parent.getChildren().size() );
|
||||
assertEquals( 0, parent.getVersion() );
|
||||
assertEquals( 1, parent.getChildren().size() );
|
||||
assertEquals( 1, parent.getVersion() );
|
||||
child = ( VersionedNode ) s.get( VersionedNode.class, child.getId() );
|
||||
assertNull( child );
|
||||
assertNotNull( child );
|
||||
s.delete( parent );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
@ -320,7 +320,7 @@ public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
|
|||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertUpdateCount( 1 );
|
||||
assertInsertCount( 1 );
|
||||
clearCounts();
|
||||
|
||||
|
@ -330,7 +330,7 @@ public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
|
|||
child = ( VersionedNode ) s.get( VersionedNode.class, child.getId() );
|
||||
assertEquals( parent.getName(), "parent" );
|
||||
assertEquals( 1, parent.getChildren().size() );
|
||||
assertEquals( 0, parent.getVersion() );
|
||||
assertEquals( 1, parent.getVersion() );
|
||||
assertSame( parent, child.getParent() );
|
||||
assertSame( child, parent.getChildren().iterator().next() );
|
||||
assertEquals( 0, child.getVersion() );
|
||||
|
@ -366,7 +366,7 @@ public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
|
|||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertUpdateCount( 1 );
|
||||
assertInsertCount( 1 );
|
||||
clearCounts();
|
||||
|
||||
|
@ -376,7 +376,7 @@ public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
|
|||
child = ( VersionedNode ) s.get( VersionedNode.class, child.getId() );
|
||||
assertEquals( parent.getName(), "parent" );
|
||||
assertEquals( 1, parent.getChildren().size() );
|
||||
assertEquals( 0, parent.getVersion() );
|
||||
assertEquals( 1, parent.getVersion() );
|
||||
assertSame( parent, child.getParent() );
|
||||
assertSame( child, parent.getChildren().iterator().next() );
|
||||
assertEquals( 0, child.getVersion() );
|
||||
|
@ -414,7 +414,7 @@ public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
|
|||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertUpdateCount( 1 );
|
||||
assertInsertCount( 1 );
|
||||
clearCounts();
|
||||
|
||||
|
@ -424,7 +424,7 @@ public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
|
|||
child = ( VersionedNode ) s.get( VersionedNode.class, child.getId() );
|
||||
assertEquals( parent.getName(), "parent" );
|
||||
assertEquals( 1, parent.getChildren().size() );
|
||||
assertEquals( 0, parent.getVersion() );
|
||||
assertEquals( 1, parent.getVersion() );
|
||||
assertSame( parent, child.getParent() );
|
||||
assertSame( child, parent.getChildren().iterator().next() );
|
||||
assertEquals( 0, child.getVersion() );
|
||||
|
@ -521,7 +521,7 @@ public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
|
|||
s.close();
|
||||
|
||||
assertUpdateCount( 0 );
|
||||
assertInsertCount( 0 );
|
||||
assertInsertCount( 1 );
|
||||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
|
@ -530,7 +530,7 @@ public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
|
|||
assertNull( child.getParent() );
|
||||
assertEquals( 0, child.getVersion() );
|
||||
parent = ( VersionedNode ) s.get( VersionedNode.class, parent.getId() );
|
||||
assertNull( parent );
|
||||
assertNotNull( parent );
|
||||
s.setReadOnly( child, true );
|
||||
s.delete( child );
|
||||
s.getTransaction().commit();
|
||||
|
|
Loading…
Reference in New Issue