Hibernate SVN: r14210 - in core/trunk: core/src/main/java/org/hibernate/loader and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2007-11-28 20:39:53 -0500 (Wed, 28 Nov 2007)
New Revision: 14210
Modified:
core/trunk/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java
core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java
core/trunk/core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java
core/trunk/testsuite/src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java
Log:
HHH-952 : corrected formatting from previous version in trunk
Modified: core/trunk/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java 2007-11-29 01:36:04 UTC (rev 14209)
+++ core/trunk/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java 2007-11-29 01:39:53 UTC (rev 14210)
@@ -1,5 +1,6 @@
//$Id: SubqueryExpression.java 7365 2005-07-04 02:40:29Z oneovthafew $
package org.hibernate.criterion;
+
import java.util.HashMap;
import org.hibernate.Criteria;
@@ -25,7 +26,7 @@
private QueryParameters params;
private Type[] types;
private CriteriaQueryTranslator innerQuery;
-
+
protected Type[] getTypes() {
return types;
}
@@ -40,22 +41,22 @@
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
-
- final SessionFactoryImplementor factory = criteriaQuery.getFactory();
+
+ final SessionFactoryImplementor factory = criteriaQuery.getFactory();
final OuterJoinLoadable persister = (OuterJoinLoadable) factory.getEntityPersister( criteriaImpl.getEntityOrClassName() );
createAndSetInnerQuery( criteriaQuery, factory );
CriteriaJoinWalker walker = new CriteriaJoinWalker(
- persister,
- innerQuery,
- factory,
- criteriaImpl,
- criteriaImpl.getEntityOrClassName(),
- new HashMap(),
- innerQuery.getRootSQLALias());
+ persister,
+ innerQuery,
+ factory,
+ criteriaImpl,
+ criteriaImpl.getEntityOrClassName(),
+ new HashMap(),
+ innerQuery.getRootSQLALias());
- String sql = walker.getSQLString();
+ String sql = walker.getSQLString();
final StringBuffer buf = new StringBuffer()
.append( toLeftSqlString(criteria, criteriaQuery) );
@@ -67,11 +68,11 @@
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
- //the following two lines were added to ensure that this.params is not null, which
- //can happen with two-deep nested subqueries
- SessionFactoryImplementor factory = criteriaQuery.getFactory();
- createAndSetInnerQuery(criteriaQuery, factory);
-
+ //the following two lines were added to ensure that this.params is not null, which
+ //can happen with two-deep nested subqueries
+ SessionFactoryImplementor factory = criteriaQuery.getFactory();
+ createAndSetInnerQuery(criteriaQuery, factory);
+
Type[] ppTypes = params.getPositionalParameterTypes();
Object[] ppValues = params.getPositionalParameterValues();
TypedValue[] tv = new TypedValue[ppTypes.length];
@@ -81,34 +82,35 @@
return tv;
}
- /**
- * Creates the inner query used to extract some useful information about
- * types, since it is needed in both methods.
- * @param criteriaQuery
- * @param factory
- */
- private void createAndSetInnerQuery(CriteriaQuery criteriaQuery, final SessionFactoryImplementor factory) {
- if ( innerQuery == null ) {
- //with two-deep subqueries, the same alias would get generated for
- //both using the old method (criteriaQuery.generateSQLAlias()), so
- //that is now used as a fallback if the main criteria alias isn't set
- String alias;
- if ( this.criteriaImpl.getAlias() == null ) {
- alias = criteriaQuery.generateSQLAlias();
- } else {
- alias = this.criteriaImpl.getAlias() + "_";
- }
+ /**
+ * Creates the inner query used to extract some useful information about
+ * types, since it is needed in both methods.
+ * @param criteriaQuery
+ * @param factory
+ */
+ private void createAndSetInnerQuery(CriteriaQuery criteriaQuery, final SessionFactoryImplementor factory) {
+ if ( innerQuery == null ) {
+ //with two-deep subqueries, the same alias would get generated for
+ //both using the old method (criteriaQuery.generateSQLAlias()), so
+ //that is now used as a fallback if the main criteria alias isn't set
+ String alias;
+ if ( this.criteriaImpl.getAlias() == null ) {
+ alias = criteriaQuery.generateSQLAlias();
+ }
+ else {
+ alias = this.criteriaImpl.getAlias() + "_";
+ }
- innerQuery = new CriteriaQueryTranslator(
- factory,
- criteriaImpl,
- criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union)
- alias,
- criteriaQuery
- );
+ innerQuery = new CriteriaQueryTranslator(
+ factory,
+ criteriaImpl,
+ criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union)
+ alias,
+ criteriaQuery
+ );
- params = innerQuery.getQueryParameters();
- types = innerQuery.getProjectedTypes();
- }
- }
+ params = innerQuery.getQueryParameters();
+ types = innerQuery.getProjectedTypes();
+ }
+ }
}
Modified: core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java 2007-11-29 01:36:04 UTC (rev 14209)
+++ core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java 2007-11-29 01:39:53 UTC (rev 14210)
@@ -1,4 +1,4 @@
-//$Id: AbstractEntityJoinWalker.java 11080 2007-01-23 16:29:18Z steve.ebersole(a)jboss.com $
+//$Id: AbstractEntityJoinWalker.java 11081 2007-01-23 16:31:13Z steve.ebersole(a)jboss.com $
package org.hibernate.loader;
import java.util.ArrayList;
@@ -20,7 +20,7 @@
/**
* Abstract walker for walkers which begin at an entity (criteria
* queries and entity loaders).
- *
+ *
* @author Gavin King
*/
public abstract class AbstractEntityJoinWalker extends JoinWalker {
@@ -55,10 +55,11 @@
getFactory(),
CollectionHelper.EMPTY_MAP
) );
-
+
initPersisters(allAssociations, lockMode);
initStatementString( whereString, orderByString, lockMode);
}
+
protected final void initProjection(
final String projectionString,
final String whereString,
Modified: core/trunk/core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java 2007-11-29 01:36:04 UTC (rev 14209)
+++ core/trunk/core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java 2007-11-29 01:39:53 UTC (rev 14210)
@@ -58,12 +58,12 @@
final Map enabledFilters) {
this(persister, translator, factory, criteria, rootEntityName, enabledFilters, null);
}
-
+
public CriteriaJoinWalker(
- final OuterJoinLoadable persister,
+ final OuterJoinLoadable persister,
final CriteriaQueryTranslator translator,
- final SessionFactoryImplementor factory,
- final CriteriaImpl criteria,
+ final SessionFactoryImplementor factory,
+ final CriteriaImpl criteria,
final String rootEntityName,
final Map enabledFilters,
final String alias) {
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java 2007-11-29 01:36:04 UTC (rev 14209)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java 2007-11-29 01:39:53 UTC (rev 14210)
@@ -1,4 +1,4 @@
-//$Id: CriteriaQueryTest.java 10977 2006-12-12 23:28:04Z steve.ebersole(a)jboss.com $
+//$Id: CriteriaQueryTest.java 10976 2006-12-12 23:22:26Z steve.ebersole(a)jboss.com $
package org.hibernate.test.criteria;
import java.util.List;
@@ -153,8 +153,8 @@
.list();
session.createCriteria(Student.class)
- .add( Property.forName("name").eqAll(dc) )
- .list();
+ .add( Property.forName("name").eqAll(dc) )
+ .list();
session.createCriteria(Student.class)
.add( Subqueries.in("Gavin King", dc) )
16 years, 12 months
Hibernate SVN: r14209 - in core/branches/Branch_3_2: src/org/hibernate/loader and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2007-11-28 20:36:04 -0500 (Wed, 28 Nov 2007)
New Revision: 14209
Modified:
core/branches/Branch_3_2/src/org/hibernate/criterion/SubqueryExpression.java
core/branches/Branch_3_2/src/org/hibernate/loader/AbstractEntityJoinWalker.java
core/branches/Branch_3_2/src/org/hibernate/loader/criteria/CriteriaJoinWalker.java
core/branches/Branch_3_2/test/org/hibernate/test/criteria/CriteriaQueryTest.java
Log:
HHH-952 : subqueries with joins using DetatchedCriteria
Modified: core/branches/Branch_3_2/src/org/hibernate/criterion/SubqueryExpression.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/criterion/SubqueryExpression.java 2007-11-28 22:10:08 UTC (rev 14208)
+++ core/branches/Branch_3_2/src/org/hibernate/criterion/SubqueryExpression.java 2007-11-29 01:36:04 UTC (rev 14209)
@@ -1,17 +1,18 @@
//$Id$
package org.hibernate.criterion;
+import java.util.HashMap;
+
import org.hibernate.Criteria;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.TypedValue;
import org.hibernate.impl.CriteriaImpl;
+import org.hibernate.loader.criteria.CriteriaJoinWalker;
import org.hibernate.loader.criteria.CriteriaQueryTranslator;
import org.hibernate.persister.entity.OuterJoinLoadable;
-import org.hibernate.sql.Select;
import org.hibernate.type.Type;
/**
@@ -24,7 +25,8 @@
private String op;
private QueryParameters params;
private Type[] types;
-
+ private CriteriaQueryTranslator innerQuery;
+
protected Type[] getTypes() {
return types;
}
@@ -39,34 +41,23 @@
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
-
- final SessionImplementor session = ( (CriteriaImpl) criteria ).getSession(); //ugly!
- final SessionFactoryImplementor factory = session.getFactory();
-
+
+ final SessionFactoryImplementor factory = criteriaQuery.getFactory();
final OuterJoinLoadable persister = (OuterJoinLoadable) factory.getEntityPersister( criteriaImpl.getEntityOrClassName() );
- CriteriaQueryTranslator innerQuery = new CriteriaQueryTranslator(
- factory,
- criteriaImpl,
- criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union)
- criteriaQuery.generateSQLAlias(),
- criteriaQuery
- );
+
+ createAndSetInnerQuery( criteriaQuery, factory );
- params = innerQuery.getQueryParameters(); //TODO: bad lifecycle....
- types = innerQuery.getProjectedTypes();
-
- //String filter = persister.filterFragment( innerQuery.getRootSQLALias(), session.getEnabledFilters() );
-
- String sql = new Select( factory.getDialect() )
- .setWhereClause( innerQuery.getWhereCondition() )
- .setGroupByClause( innerQuery.getGroupBy() )
- .setSelectClause( innerQuery.getSelect() )
- .setFromClause(
- persister.fromTableFragment( innerQuery.getRootSQLALias() ) +
- persister.fromJoinFragment( innerQuery.getRootSQLALias(), true, false )
- )
- .toStatementString();
-
+ CriteriaJoinWalker walker = new CriteriaJoinWalker(
+ persister,
+ innerQuery,
+ factory,
+ criteriaImpl,
+ criteriaImpl.getEntityOrClassName(),
+ new HashMap(),
+ innerQuery.getRootSQLALias());
+
+ String sql = walker.getSQLString();
+
final StringBuffer buf = new StringBuffer()
.append( toLeftSqlString(criteria, criteriaQuery) );
if (op!=null) buf.append(' ').append(op).append(' ');
@@ -77,13 +68,49 @@
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
- Type[] types = params.getPositionalParameterTypes();
- Object[] values = params.getPositionalParameterValues();
- TypedValue[] tv = new TypedValue[types.length];
- for ( int i=0; i<types.length; i++ ) {
- tv[i] = new TypedValue( types[i], values[i], EntityMode.POJO );
+ //the following two lines were added to ensure that this.params is not null, which
+ //can happen with two-deep nested subqueries
+ SessionFactoryImplementor factory = criteriaQuery.getFactory();
+ createAndSetInnerQuery(criteriaQuery, factory);
+
+ Type[] ppTypes = params.getPositionalParameterTypes();
+ Object[] ppValues = params.getPositionalParameterValues();
+ TypedValue[] tv = new TypedValue[ppTypes.length];
+ for ( int i=0; i<ppTypes.length; i++ ) {
+ tv[i] = new TypedValue( ppTypes[i], ppValues[i], EntityMode.POJO );
}
return tv;
}
+ /**
+ * Creates the inner query used to extract some useful information about
+ * types, since it is needed in both methods.
+ * @param criteriaQuery
+ * @param factory
+ */
+ private void createAndSetInnerQuery(CriteriaQuery criteriaQuery, final SessionFactoryImplementor factory) {
+ if ( innerQuery == null ) {
+ //with two-deep subqueries, the same alias would get generated for
+ //both using the old method (criteriaQuery.generateSQLAlias()), so
+ //that is now used as a fallback if the main criteria alias isn't set
+ String alias;
+ if ( this.criteriaImpl.getAlias() == null ) {
+ alias = criteriaQuery.generateSQLAlias();
+ }
+ else {
+ alias = this.criteriaImpl.getAlias() + "_";
+ }
+
+ innerQuery = new CriteriaQueryTranslator(
+ factory,
+ criteriaImpl,
+ criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union)
+ alias,
+ criteriaQuery
+ );
+
+ params = innerQuery.getQueryParameters();
+ types = innerQuery.getProjectedTypes();
+ }
+ }
}
Modified: core/branches/Branch_3_2/src/org/hibernate/loader/AbstractEntityJoinWalker.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/loader/AbstractEntityJoinWalker.java 2007-11-28 22:10:08 UTC (rev 14208)
+++ core/branches/Branch_3_2/src/org/hibernate/loader/AbstractEntityJoinWalker.java 2007-11-29 01:36:04 UTC (rev 14209)
@@ -26,12 +26,16 @@
public abstract class AbstractEntityJoinWalker extends JoinWalker {
private final OuterJoinLoadable persister;
- private String alias;
+ private final String alias;
public AbstractEntityJoinWalker(OuterJoinLoadable persister, SessionFactoryImplementor factory, Map enabledFilters) {
+ this( persister, factory, enabledFilters, null );
+ }
+
+ public AbstractEntityJoinWalker(OuterJoinLoadable persister, SessionFactoryImplementor factory, Map enabledFilters, String alias) {
super( factory, enabledFilters );
this.persister = persister;
- alias = generateRootAlias( persister.getEntityName() );
+ this.alias = ( alias == null ) ? generateRootAlias( persister.getEntityName() ) : alias;
}
protected final void initAll(
@@ -39,9 +43,7 @@
final String orderByString,
final LockMode lockMode)
throws MappingException {
-
walkEntityTree( persister, getAlias() );
-
List allAssociations = new ArrayList();
allAssociations.addAll(associations);
allAssociations.add( new OuterJoinableAssociation(
Modified: core/branches/Branch_3_2/src/org/hibernate/loader/criteria/CriteriaJoinWalker.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/loader/criteria/CriteriaJoinWalker.java 2007-11-28 22:10:08 UTC (rev 14208)
+++ core/branches/Branch_3_2/src/org/hibernate/loader/criteria/CriteriaJoinWalker.java 2007-11-29 01:36:04 UTC (rev 14209)
@@ -8,7 +8,6 @@
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
-import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
import org.hibernate.engine.CascadeStyle;
@@ -18,7 +17,6 @@
import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.persister.entity.Queryable;
-import org.hibernate.sql.JoinFragment;
import org.hibernate.type.AssociationType;
import org.hibernate.type.Type;
import org.hibernate.type.TypeFactory;
@@ -57,10 +55,20 @@
final SessionFactoryImplementor factory,
final CriteriaImpl criteria,
final String rootEntityName,
- final Map enabledFilters)
- throws HibernateException {
- super(persister, factory, enabledFilters);
+ final Map enabledFilters) {
+ this(persister, translator, factory, criteria, rootEntityName, enabledFilters, null);
+ }
+ public CriteriaJoinWalker(
+ final OuterJoinLoadable persister,
+ final CriteriaQueryTranslator translator,
+ final SessionFactoryImplementor factory,
+ final CriteriaImpl criteria,
+ final String rootEntityName,
+ final Map enabledFilters,
+ final String alias) {
+ super(persister, factory, enabledFilters, alias);
+
this.translator = translator;
querySpaces = translator.getQuerySpaces();
Modified: core/branches/Branch_3_2/test/org/hibernate/test/criteria/CriteriaQueryTest.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/criteria/CriteriaQueryTest.java 2007-11-28 22:10:08 UTC (rev 14208)
+++ core/branches/Branch_3_2/test/org/hibernate/test/criteria/CriteriaQueryTest.java 2007-11-29 01:36:04 UTC (rev 14209)
@@ -16,7 +16,6 @@
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Example;
-import org.hibernate.criterion.Expression;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projection;
@@ -154,8 +153,8 @@
.list();
session.createCriteria(Student.class)
- .add( Property.forName("name").eqAll(dc) )
- .list();
+ .add( Property.forName("name").eqAll(dc) )
+ .list();
session.createCriteria(Student.class)
.add( Subqueries.in("Gavin King", dc) )
@@ -169,8 +168,7 @@
.add( Subqueries.eq("Gavin King", dc2) )
.list();
- //TODO: join in subselect: HHH-952
- /*DetachedCriteria dc3 = DetachedCriteria.forClass(Student.class, "st")
+ DetachedCriteria dc3 = DetachedCriteria.forClass(Student.class, "st")
.createCriteria("enrolments")
.createCriteria("course")
.add( Property.forName("description").eq("Hibernate Training") )
@@ -178,7 +176,7 @@
session.createCriteria(Enrolment.class, "e")
.add( Subqueries.eq("Gavin King", dc3) )
- .list();*/
+ .list();
session.delete(enrolment2);
session.delete(gavin);
@@ -398,8 +396,8 @@
.add( Projections.property("studentNumber"), "stNumber" )
.add( Projections.property("courseCode"), "cCode" ) )
)
- .add( Expression.gt( "studentNumber", new Long(665) ) )
- .add( Expression.lt( "studentNumber", new Long(668) ) )
+ .add( Restrictions.gt( "studentNumber", new Long(665) ) )
+ .add( Restrictions.lt( "studentNumber", new Long(668) ) )
.addOrder( Order.asc("stNumber") )
.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)
.list();
16 years, 12 months
Hibernate SVN: r14208 - in core/branches/Branch_3_2_4_SP1_CP: test/org/hibernate/test/component/basic and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: cbredesen
Date: 2007-11-28 17:10:08 -0500 (Wed, 28 Nov 2007)
New Revision: 14208
Added:
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/OptionalComponent.java
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/TypeFactory.java
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/ComponentTest.java
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/Employee.java
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/User.hbm.xml
Log:
JBPAPP-357 - HHH-2542 - NullPointerException in TypeFactory.replaceAssociations for ComponentType
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/TypeFactory.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/TypeFactory.java 2007-11-28 21:19:33 UTC (rev 14207)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/type/TypeFactory.java 2007-11-28 22:10:08 UTC (rev 14208)
@@ -553,7 +553,7 @@
AbstractComponentType componentType = ( AbstractComponentType ) types[i];
Type[] subtypes = componentType.getSubtypes();
Object[] origComponentValues = original[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( original[i], session );
- Object[] targetComponentValues = componentType.getPropertyValues( target[i], session );
+ Object[] targetComponentValues = target[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( target[i], session );
replaceAssociations( origComponentValues, targetComponentValues, subtypes, session, null, copyCache, foreignKeyDirection );
copied[i] = target[i];
}
Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/ComponentTest.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/ComponentTest.java 2007-11-28 21:19:33 UTC (rev 14207)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/ComponentTest.java 2007-11-28 22:10:08 UTC (rev 14208)
@@ -9,6 +9,7 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.Hibernate;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.Mappings;
@@ -190,5 +191,131 @@
s.close();
}
+ public void testMergeComponent() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ Employee emp = new Employee();
+ emp.setHireDate( new Date() );
+ emp.setPerson( new Person() );
+ emp.getPerson().setName( "steve" );
+ emp.getPerson().setDob( new Date() );
+ s.persist( emp );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.get( Employee.class, emp.getId() );
+ t.commit();
+ s.close();
+
+ assertNull(emp.getOptionalComponent());
+ emp.setOptionalComponent( new OptionalComponent() );
+ emp.getOptionalComponent().setValue1( "emp-value1" );
+ emp.getOptionalComponent().setValue2( "emp-value2" );
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.merge( emp );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.get( Employee.class, emp.getId() );
+ t.commit();
+ s.close();
+
+ assertEquals("emp-value1", emp.getOptionalComponent().getValue1());
+ assertEquals("emp-value2", emp.getOptionalComponent().getValue2());
+ emp.getOptionalComponent().setValue1( null );
+ emp.getOptionalComponent().setValue2( null );
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.merge( emp );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.get( Employee.class, emp.getId() );
+ Hibernate.initialize(emp.getDirectReports());
+ t.commit();
+ s.close();
+
+ assertNull(emp.getOptionalComponent());
+
+ Employee emp1 = new Employee();
+ emp1.setHireDate( new Date() );
+ emp1.setPerson( new Person() );
+ emp1.getPerson().setName( "bozo" );
+ emp1.getPerson().setDob( new Date() );
+ emp.getDirectReports().add( emp1 );
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.merge( emp );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.get( Employee.class, emp.getId() );
+ Hibernate.initialize(emp.getDirectReports());
+ t.commit();
+ s.close();
+
+ assertEquals(1, emp.getDirectReports().size());
+ emp1 = (Employee)emp.getDirectReports().iterator().next();
+ assertNull( emp1.getOptionalComponent() );
+ emp1.setOptionalComponent( new OptionalComponent() );
+ emp1.getOptionalComponent().setValue1( "emp1-value1" );
+ emp1.getOptionalComponent().setValue2( "emp1-value2" );
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.merge( emp );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.get( Employee.class, emp.getId() );
+ Hibernate.initialize(emp.getDirectReports());
+ t.commit();
+ s.close();
+
+ assertEquals(1, emp.getDirectReports().size());
+ emp1 = (Employee)emp.getDirectReports().iterator().next();
+ assertEquals( "emp1-value1", emp1.getOptionalComponent().getValue1());
+ assertEquals( "emp1-value2", emp1.getOptionalComponent().getValue2());
+ emp1.getOptionalComponent().setValue1( null );
+ emp1.getOptionalComponent().setValue2( null );
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.merge( emp );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ emp = (Employee)s.get( Employee.class, emp.getId() );
+ Hibernate.initialize(emp.getDirectReports());
+ t.commit();
+ s.close();
+
+ assertEquals(1, emp.getDirectReports().size());
+ emp1 = (Employee)emp.getDirectReports().iterator().next();
+ assertNull(emp1.getOptionalComponent());
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.delete( emp );
+ t.commit();
+ s.close();
+ }
+
}
Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/Employee.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/Employee.java 2007-11-28 21:19:33 UTC (rev 14207)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/Employee.java 2007-11-28 22:10:08 UTC (rev 14208)
@@ -1,38 +1,58 @@
-package org.hibernate.test.component.basic;
-
-import java.util.Date;
-
-/**
- * todo: describe Employee
- *
- * @author Steve Ebersole
- */
-public class Employee {
- private Long id;
- private Person person;
- private Date hireDate;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public Person getPerson() {
- return person;
- }
-
- public void setPerson(Person person) {
- this.person = person;
- }
-
- public Date getHireDate() {
- return hireDate;
- }
-
- public void setHireDate(Date hireDate) {
- this.hireDate = hireDate;
- }
-}
+package org.hibernate.test.component.basic;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * todo: describe Employee
+ *
+ * @author Steve Ebersole
+ */
+public class Employee {
+ private Long id;
+ private Person person;
+ private Date hireDate;
+ private OptionalComponent optionalComponent;
+ private Set directReports = new HashSet();
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+
+ public Date getHireDate() {
+ return hireDate;
+ }
+
+ public void setHireDate(Date hireDate) {
+ this.hireDate = hireDate;
+ }
+
+ public OptionalComponent getOptionalComponent() {
+ return optionalComponent;
+ }
+
+ public void setOptionalComponent(OptionalComponent optionalComponent) {
+ this.optionalComponent = optionalComponent;
+ }
+
+ public Set getDirectReports() {
+ return directReports;
+ }
+
+ public void setDirectReports(Set directReports) {
+ this.directReports = directReports;
+ }
+}
Added: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/OptionalComponent.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/OptionalComponent.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/OptionalComponent.java 2007-11-28 22:10:08 UTC (rev 14208)
@@ -0,0 +1,27 @@
+//$Id: $
+package org.hibernate.test.component.basic;
+
+/**
+ * @author Gail Badner
+ */
+
+public class OptionalComponent {
+ private String value1;
+ private String value2;
+
+ public String getValue1() {
+ return value1;
+ }
+
+ public void setValue1(String value1) {
+ this.value1 = value1;
+ }
+
+ public String getValue2() {
+ return value2;
+ }
+
+ public void setValue2(String value2) {
+ this.value2 = value2;
+ }
+}
Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/User.hbm.xml
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/User.hbm.xml 2007-11-28 21:19:33 UTC (rev 14207)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/component/basic/User.hbm.xml 2007-11-28 22:10:08 UTC (rev 14208)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
+<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
@@ -8,7 +8,7 @@
-->
<hibernate-mapping package="org.hibernate.test.component.basic">
-
+
<class name="User" table="T_USER">
<id name="userName"/>
<timestamp name="lastModified"/>
@@ -19,9 +19,9 @@
<property name="address"/>
<property name="previousAddress" insert="false"/>
<property name="yob" formula="year(dob)"/>
- <property name="currentAddress"
- column="address"
- insert="false"
+ <property name="currentAddress"
+ column="address"
+ insert="false"
update="false"/>
</component>
</class>
@@ -35,8 +35,16 @@
<property name="name" update="false" not-null="true"/>
<property name="dob" update="false" not-null="true"/>
</component>
+ <component name="optionalComponent">
+ <property name="value1" not-null="false"/>
+ <property name="value2" not-null="false"/>
+ </component>
+ <set name="directReports" cascade="all-delete-orphan,merge" lazy="true">
+ <key column="PARENT_ID" />
+ <one-to-many class="Employee"/>
+ </set>
</class>
-
+
<query name="userNameIn"><![CDATA[from User where person.name in (:nameList) or userName in (:nameList)]]></query>
-
+
</hibernate-mapping>
16 years, 12 months
Hibernate SVN: r14207 - core/trunk/cache-jbosscache2.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2007-11-28 16:19:33 -0500 (Wed, 28 Nov 2007)
New Revision: 14207
Modified:
core/trunk/cache-jbosscache2/pom.xml
Log:
Add some config tweaks to pom to help people who have trouble with multicast during testsuite runs
Modified: core/trunk/cache-jbosscache2/pom.xml
===================================================================
--- core/trunk/cache-jbosscache2/pom.xml 2007-11-28 17:37:22 UTC (rev 14206)
+++ core/trunk/cache-jbosscache2/pom.xml 2007-11-28 21:19:33 UTC (rev 14207)
@@ -85,7 +85,32 @@
<name>hibernate.test.validatefailureexpected</name>
<value>true</value>
</property>
+ <!-- If you find the testsuite runs very slowly, there
+ may be problems with multicast on the interface
+ JGroups uses by default. You can try to resolve
+ this by uncommenting this property and setting the
+ value to an interface where you know multicast works
+ <property>
+ <name>jgroups.bind_addr</name>
+ <value>192.168.0.1</value>
+ </property>
+ -->
+ <!-- There are problems with multicast and IPv6 on some
+ OS/JDK combos, so we tell Java to use IPv4. If you
+ have problems with multicast when running the tests
+ you can try setting this to 'false', although typically
+ that won't be helpful.
+ -->
+ <property>
+ <name>java.net.preferIPv4Stack</name>
+ <value>true</value>
+ </property>
</systemProperties>
+ <!-- If all else fails and you cannot get multicast working
+ properly for the testsuite, uncomment this to disable the
+ tests.
+ <skipExec>true</skipExec>
+ -->
</configuration>
</plugin>
</plugins>
16 years, 12 months
Hibernate SVN: r14206 - core/trunk/core.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-11-28 12:37:22 -0500 (Wed, 28 Nov 2007)
New Revision: 14206
Modified:
core/trunk/core/pom.xml
Log:
update antlr plugin version based on their latest SVN
Modified: core/trunk/core/pom.xml
===================================================================
--- core/trunk/core/pom.xml 2007-11-27 18:44:02 UTC (rev 14205)
+++ core/trunk/core/pom.xml 2007-11-28 17:37:22 UTC (rev 14206)
@@ -22,7 +22,7 @@
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
- <version>${antlr.version}</version>
+ <version>${antlrVersion}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
@@ -85,12 +85,12 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>antlr-maven-plugin</artifactId>
- <version>2.0-SNAPSHOT</version>
+ <version>${antlrPluginVersion}</version>
<dependencies>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
- <version>${antlr.version}</version>
+ <version>${antlrVersion}</version>
</dependency>
</dependencies>
<configuration>
@@ -112,7 +112,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>antlr-maven-plugin</artifactId>
- <version>2.0-SNAPSHOT</version>
+ <version>${antlrPluginVersion}</version>
<configuration>
<!-- eventually should be based on the second phase grammar -->
<grammars>hql.g</grammars>
@@ -150,7 +150,8 @@
</reporting>
<properties>
- <antlr.version>2.7.6</antlr.version>
+ <antlrVersion>2.7.6</antlrVersion>
+ <antlrPluginVersion>2.0.0-SNAPSHOT</antlrPluginVersion>
</properties>
</project>
16 years, 12 months
Hibernate SVN: r14205 - in branches/Branch_3_2/HibernateExt/tools: src/java/org/hibernate/tool and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-27 13:44:02 -0500 (Tue, 27 Nov 2007)
New Revision: 14205
Modified:
branches/Branch_3_2/HibernateExt/tools/build.xml
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
Log:
bump version
Modified: branches/Branch_3_2/HibernateExt/tools/build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/build.xml 2007-11-22 00:22:48 UTC (rev 14204)
+++ branches/Branch_3_2/HibernateExt/tools/build.xml 2007-11-27 18:44:02 UTC (rev 14205)
@@ -7,7 +7,7 @@
<!-- Name of project and version, used to create filenames -->
<property name="Name" value="Hibernate Tools"/>
<property name="name" value="hibernate-tools"/>
- <property name="version" value="3.2.0.CR1"/>
+ <property name="version" value="3.2.0.GA"/>
<property name="javadoc.packagenames" value="org.hibernate.tool"/>
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java 2007-11-22 00:22:48 UTC (rev 14204)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java 2007-11-27 18:44:02 UTC (rev 14205)
@@ -5,7 +5,7 @@
final public class Version {
- public static final String VERSION = "3.2.0.CR1";
+ public static final String VERSION = "3.2.0.GA";
private static final Version instance = new Version();
16 years, 12 months
Hibernate SVN: r14204 - search/trunk/src/java/org/hibernate/search/backend/impl/jms.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-11-21 19:22:48 -0500 (Wed, 21 Nov 2007)
New Revision: 14204
Modified:
search/trunk/src/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessorFactory.java
Log:
HSEARCH-138 JNDI additional properties name has its first character truncated
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessorFactory.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessorFactory.java 2007-11-19 17:12:16 UTC (rev 14203)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/jms/JMSBackendQueueProcessorFactory.java 2007-11-22 00:22:48 UTC (rev 14204)
@@ -99,7 +99,7 @@
String prop = (String) iter.next();
if ( prop.indexOf( JNDI_PREFIX ) > -1 && !specialProps.contains( prop ) ) {
result.setProperty(
- prop.substring( JNDI_PREFIX.length() + 1 ),
+ prop.substring( JNDI_PREFIX.length() ),
properties.getProperty( prop )
);
}
17 years
Hibernate SVN: r14203 - annotations/trunk/src/test/org/hibernate/test/annotations.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-11-19 12:12:16 -0500 (Mon, 19 Nov 2007)
New Revision: 14203
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/EntityTest.java
Log:
wrong test
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/EntityTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/EntityTest.java 2007-11-19 17:09:43 UTC (rev 14202)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/EntityTest.java 2007-11-19 17:12:16 UTC (rev 14203)
@@ -322,12 +322,13 @@
Query q = s.createQuery( "from Flight f where f.departureDate = :departureDate" );
q.setParameter( "departureDate", airFrance.getDepartureDate(), Hibernate.DATE );
Flight copyAirFrance = (Flight) q.uniqueResult();
- assertNotNull( airFrance );
+ assertNotNull( copyAirFrance );
assertEquals(
new Date( 05, 06, 21 ),
copyAirFrance.getDepartureDate()
);
assertEquals( copyAirFrance.getBuyDate().getTime() / 1000 , airFrance.getBuyDate().getTime() / 1000 );
+
s.delete( copyAirFrance );
tx.commit();
s.close();
17 years
Hibernate SVN: r14202 - annotations/trunk/src/test/org/hibernate/test/annotations.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-11-19 12:09:43 -0500 (Mon, 19 Nov 2007)
New Revision: 14202
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/EntityTest.java
Log:
typo in test
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/EntityTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/EntityTest.java 2007-11-16 20:26:30 UTC (rev 14201)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/EntityTest.java 2007-11-19 17:09:43 UTC (rev 14202)
@@ -327,7 +327,7 @@
new Date( 05, 06, 21 ),
copyAirFrance.getDepartureDate()
);
- assertEquals( airFrance.getBuyDate().getTime() / 1000 , airFrance.getBuyDate().getTime() / 1000 );
+ assertEquals( copyAirFrance.getBuyDate().getTime() / 1000 , airFrance.getBuyDate().getTime() / 1000 );
s.delete( copyAirFrance );
tx.commit();
s.close();
17 years
Hibernate SVN: r14201 - in core/branches/Branch_3_2: test/org/hibernate/test/hql and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-11-16 15:26:30 -0500 (Fri, 16 Nov 2007)
New Revision: 14201
Modified:
core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java
core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java
Log:
HHH-2833 : insert-select query fails with NPE when select includes join
Modified: core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java 2007-11-16 20:25:59 UTC (rev 14200)
+++ core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java 2007-11-16 20:26:30 UTC (rev 14201)
@@ -336,7 +336,8 @@
joinIsNeeded = generateJoin && !isReferenceToPrimaryKey( parentAsDotNode.propertyName, entityType );
}
else if ( ! getWalker().isSelectStatement() ) {
- joinIsNeeded = false;
+ // in non-select queries, the only time we should need to join is if we are in a subquery from clause
+ joinIsNeeded = getWalker().getCurrentStatementType() == SqlTokenTypes.SELECT && getWalker().isInFrom();
}
else if ( REGRESSION_STYLE_JOIN_SUPPRESSION ) {
// this is the regression style determination which matches the logic of the classic translator
Modified: core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java
===================================================================
--- core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java 2007-11-16 20:25:59 UTC (rev 14200)
+++ core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java 2007-11-16 20:26:30 UTC (rev 14201)
@@ -451,6 +451,17 @@
s.close();
}
+ public void testInsertWithSelectListUsingJoins() {
+ // this is just checking parsing and syntax...
+ Session s = openSession();
+ s.beginTransaction();
+ s.createQuery( "insert into Animal (description, bodyWeight) select h.description, h.bodyWeight from Human h where h.mother.mother is not null" ).executeUpdate();
+ s.createQuery( "delete from Animal" ).executeUpdate();
+ s.getTransaction().commit();
+ s.close();
+ }
+
+
// UPDATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public void testIncorrectSyntax() {
17 years