Hibernate SVN: r18413 - in core/trunk/annotations/src: test/java/org/hibernate/test/annotations/embedded and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-01-05 11:11:14 -0500 (Tue, 05 Jan 2010)
New Revision: 18413
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/TableBinder.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java
Log:
HHH-4753 Default table name for @CollectionTable is not inferred correctly according to spec requirement. Legacy names still supported.
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-05 14:06:38 UTC (rev 18412)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-05 16:11:14 UTC (rev 18413)
@@ -1225,6 +1225,7 @@
joinColumns[0].getPropertyName()
);
}
+ associationTableBinder.setJPA2ElementCollection( !isCollectionOfEntities && property.isAnnotationPresent( ElementCollection.class ));
collValue.setCollectionTable( associationTableBinder.bind() );
}
bindFilters( isCollectionOfEntities );
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/TableBinder.java 2010-01-05 14:06:38 UTC (rev 18412)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/TableBinder.java 2010-01-05 16:11:14 UTC (rev 18413)
@@ -77,6 +77,7 @@
private String propertyName;
private String ownerEntity;
private String associatedEntity;
+ private boolean isJPA2ElementCollection;
public void setSchema(String schema) {
this.schema = schema;
@@ -114,6 +115,10 @@
this.mappings = mappings;
}
+ public void setJPA2ElementCollection(boolean isJPA2ElementCollection) {
+ this.isJPA2ElementCollection = isJPA2ElementCollection;
+ }
+
private static class AssociationTableNameSource implements ObjectNameSource {
private final String explicitName;
private final String logicalName;
@@ -138,15 +143,20 @@
final String unquotedOwnerTable = StringHelper.unquote( ownerEntityTable );
final String unquotedAssocTable = StringHelper.unquote( associatedEntityTable );
- final ObjectNameSource nameSource = buildNameContext( unquotedOwnerTable, unquotedAssocTable );
+ //@ElementCollection use ownerEntity_property instead of the cleaner ownerTableName_property
+ final String ownerObjectName = isJPA2ElementCollection ? StringHelper.unqualify( ownerEntity ) : unquotedOwnerTable;
+ final ObjectNameSource nameSource = buildNameContext(
+ ownerObjectName,
+ unquotedAssocTable );
final boolean ownerEntityTableQuoted = StringHelper.isQuoted( ownerEntityTable );
final boolean associatedEntityTableQuoted = StringHelper.isQuoted( associatedEntityTable );
final ObjectNameNormalizer.NamingStrategyHelper namingStrategyHelper = new ObjectNameNormalizer.NamingStrategyHelper() {
public String determineImplicitName(NamingStrategy strategy) {
+
final String strategyResult = strategy.collectionTableName(
ownerEntity,
- unquotedOwnerTable,
+ ownerObjectName,
associatedEntity,
unquotedAssocTable,
propertyName
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java 2010-01-05 14:06:38 UTC (rev 18412)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java 2010-01-05 16:11:14 UTC (rev 18413)
@@ -11,6 +11,7 @@
import org.hibernate.test.annotations.TestCase;
import org.hibernate.test.annotations.embedded.FloatLeg.RateIndex;
import org.hibernate.test.annotations.embedded.Leg.Frequency;
+import org.hibernate.test.util.SchemaUtil;
/**
* @author Emmanuel Bernard
@@ -365,8 +366,13 @@
s.close();
}
- // quick test based on testSimple
- public void testCollectionTable() throws Exception {
+ public void testDefaultCollectionTable() throws Exception {
+ //are the tables correct?
+ assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", getCfg() ) );
+ assertTrue( SchemaUtil.isTablePresent("PersonEmbed_legacyVacationHomes", getCfg() ) );
+ assertTrue( SchemaUtil.isTablePresent("WelPers_VacHomes", getCfg() ) );
+
+ //just to make sure, use the mapping
Session s;
Transaction tx;
WealthyPerson p = new WealthyPerson();
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java 2010-01-05 14:06:38 UTC (rev 18412)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java 2010-01-05 16:11:14 UTC (rev 18413)
@@ -14,18 +14,27 @@
import java.util.HashSet;
import java.util.Set;
+import org.hibernate.annotations.CollectionOfElements;
+
@Entity
public class WealthyPerson extends Person {
@ElementCollection
- @CollectionTable(name="XXXHOMES")
- @AttributeOverrides({
- @AttributeOverride(name="address1",
- column=@Column(name="HOME_STREET")),
- @AttributeOverride(name="city",
- column=@Column(name="HOME_CITY")),
- @AttributeOverride(name="country",
- column=@Column(name="HOME_COUNTRY"))
- })
+// @CollectionTable(name="XXXHOMES")
+// @AttributeOverrides({
+// @AttributeOverride(name="address1",
+// column=@Column(name="HOME_STREET")),
+// @AttributeOverride(name="city",
+// column=@Column(name="HOME_CITY")),
+// @AttributeOverride(name="country",
+// column=@Column(name="HOME_COUNTRY"))
+// })
protected Set<Address> vacationHomes = new HashSet<Address>();
+
+ @CollectionOfElements
+ protected Set<Address> legacyVacationHomes = new HashSet<Address>();
+
+ @CollectionOfElements
+ @CollectionTable(name = "WelPers_VacHomes")
+ protected Set<Address> explicitVacationHomes = new HashSet<Address>();
}
14 years, 11 months
Hibernate SVN: r18412 - core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-05 09:06:38 -0500 (Tue, 05 Jan 2010)
New Revision: 18412
Modified:
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQL.hbm.xml
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQLTest.java
Log:
JBPAPP-3325 org.hibernate.test.legacy.CustomSQLTest.testInsert fails on most of DBs
Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQL.hbm.xml
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQL.hbm.xml 2010-01-05 13:45:24 UTC (rev 18411)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQL.hbm.xml 2010-01-05 14:06:38 UTC (rev 18412)
@@ -38,7 +38,7 @@
deleteAllRoleBunchOfString(?)}</sql-delete-all>
</list>
- <sql-insert>insert into "Role" (name) values (?) /** i did this*/</sql-insert>
+ <sql-insert>insert into "Role" (name,id) values (?,?) /** i did this*/</sql-insert>
<sql-delete>delete from "Role" where id=?</sql-delete>
</class>
Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQLTest.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQLTest.java 2010-01-05 13:45:24 UTC (rev 18411)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQLTest.java 2010-01-05 14:06:38 UTC (rev 18412)
@@ -11,6 +11,7 @@
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
import org.hibernate.classic.Session;
import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.dialect.SybaseDialect;
/**
* @author MAX
@@ -31,7 +32,7 @@
}
public void testInsert() throws HibernateException, SQLException {
- if(getDialect() instanceof MySQLDialect)return;
+ if(getDialect() instanceof MySQLDialect || getDialect() instanceof SybaseDialect)return;
Role p = new Role();
14 years, 11 months
Hibernate SVN: r18411 - core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-05 08:45:24 -0500 (Tue, 05 Jan 2010)
New Revision: 18411
Modified:
core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQL.hbm.xml
Log:
JBPAPP-3325 Role is a keyword on sybase
Modified: core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQL.hbm.xml
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQL.hbm.xml 2010-01-05 11:01:07 UTC (rev 18410)
+++ core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/legacy/CustomSQL.hbm.xml 2010-01-05 13:45:24 UTC (rev 18411)
@@ -4,7 +4,7 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false"
package="org.hibernate.test.legacy">
- <class name="Role">
+ <class name="Role" table="`Role`">
<id name="id" type="long">
<generator class="native" />
@@ -38,8 +38,8 @@
deleteAllRoleBunchOfString(?)}</sql-delete-all>
</list>
- <sql-insert>insert into Role (name) values (?) /** i did this*/</sql-insert>
- <sql-delete>delete from Role where id=?</sql-delete>
+ <sql-insert>insert into "Role" (name) values (?) /** i did this*/</sql-insert>
+ <sql-delete>delete from "Role" where id=?</sql-delete>
</class>
14 years, 11 months
Hibernate SVN: r18410 - core/branches/Branch_3_3/core/src/main/java/org/hibernate/context.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-01-05 06:01:07 -0500 (Tue, 05 Jan 2010)
New Revision: 18410
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
Log:
HHH-4749 Don't block calls to getListeners on SessionImplementor when using thread scoped sessions
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java 2010-01-05 10:53:42 UTC (rev 18409)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java 2010-01-05 11:01:07 UTC (rev 18410)
@@ -311,7 +311,9 @@
|| "equals".equals( method.getName() )
|| "hashCode".equals( method.getName() )
|| "getStatistics".equals( method.getName() )
- || "isOpen".equals( method.getName() ) ) {
+ || "isOpen".equals( method.getName() )
+ || "getListeners".equals( method.getName() ) //useful for HSearch in particular
+ ) {
// allow these to go through the the real session no matter what
}
else if ( !realSession.isOpen() ) {
14 years, 11 months
Hibernate SVN: r18409 - in search/trunk: src/main/java/org/hibernate/search/impl and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-01-05 05:53:42 -0500 (Tue, 05 Jan 2010)
New Revision: 18409
Modified:
search/trunk/pom.xml
search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java
search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java
Log:
HSEARCH-437 Add test to theadbound session wrapped out of transaction
Implement latest version of the Session Query interfaces
use latest snapshot
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2010-01-05 10:46:13 UTC (rev 18408)
+++ search/trunk/pom.xml 2010-01-05 10:53:42 UTC (rev 18409)
@@ -58,7 +58,7 @@
<properties>
<slf4jVersion>1.5.8</slf4jVersion>
<luceneVersion>2.4.1</luceneVersion>
- <hibernateVersion>3.5.0-Beta-2</hibernateVersion>
+ <hibernateVersion>3.5.0-SNAPSHOT</hibernateVersion>
<hibernateCommonsAnnotationVersion>3.2.0.Beta1</hibernateCommonsAnnotationVersion>
</properties>
Modified: search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java 2010-01-05 10:46:13 UTC (rev 18408)
+++ search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java 2010-01-05 10:53:42 UTC (rev 18409)
@@ -49,6 +49,7 @@
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.UnknownProfileException;
+import org.hibernate.LockOptions;
import org.hibernate.classic.Session;
import org.hibernate.collection.PersistentCollection;
import org.hibernate.engine.EntityKey;
@@ -57,6 +58,7 @@
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.LoadQueryInfluencers;
+import org.hibernate.engine.NonFlushedChanges;
import org.hibernate.engine.query.ParameterMetadata;
import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.event.EventListeners;
@@ -386,6 +388,10 @@
return session.get( clazz, id, lockMode );
}
+ public Object get(Class clazz, Serializable id, LockOptions lockOptions) throws HibernateException {
+ return session.get(clazz, id, lockOptions);
+ }
+
public Object get(String entityName, Serializable id) throws HibernateException {
return session.get( entityName, id );
}
@@ -394,6 +400,10 @@
return session.get( entityName, id, lockMode );
}
+ public Object get(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException {
+ return session.get(entityName, id, lockOptions);
+ }
+
public CacheMode getCacheMode() {
return session.getCacheMode();
}
@@ -556,6 +566,14 @@
return sessionImplementor.executeNativeUpdate( specification, queryParameters );
}
+ public NonFlushedChanges getNonFlushedChanges() throws HibernateException {
+ return sessionImplementor.getNonFlushedChanges();
+ }
+
+ public void applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) throws HibernateException {
+ sessionImplementor.applyNonFlushedChanges( nonFlushedChanges );
+ }
+
public EntityMode getEntityMode() {
return session.getEntityMode();
}
@@ -644,6 +662,10 @@
return session.load( entityName, id, lockMode );
}
+ public Object load(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException {
+ return session.load( entityName, id, lockOptions );
+ }
+
public void load(Object object, Serializable id) throws HibernateException {
session.load( object, id );
}
@@ -656,10 +678,18 @@
return session.load( theClass, id, lockMode );
}
+ public Object load(Class theClass, Serializable id, LockOptions lockOptions) throws HibernateException {
+ return session.load( theClass, id, lockOptions );
+ }
+
public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException {
session.lock( entityName, object, lockMode );
}
+ public LockRequest buildLockRequest(LockOptions lockOptions) {
+ return session.buildLockRequest( lockOptions );
+ }
+
public void lock(Object object, LockMode lockMode) throws HibernateException {
session.lock( object, lockMode );
}
@@ -696,6 +726,10 @@
session.refresh( object, lockMode );
}
+ public void refresh(Object object, LockOptions lockOptions) throws HibernateException {
+ session.refresh( object, lockOptions );
+ }
+
public void replicate(String entityName, Object object, ReplicationMode replicationMode) throws HibernateException {
session.replicate( entityName, object, replicationMode );
}
Modified: search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java 2010-01-05 10:46:13 UTC (rev 18408)
+++ search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java 2010-01-05 10:53:42 UTC (rev 18409)
@@ -57,6 +57,7 @@
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
+import org.hibernate.LockOptions;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.query.ParameterMetadata;
import org.hibernate.impl.AbstractQueryImpl;
@@ -877,6 +878,10 @@
return this;
}
+ public Query setLockOptions(LockOptions lockOptions) {
+ throw new UnsupportedOperationException( "Lock options are not implemented in Hibernate Search queries");
+ }
+
@Override
public FullTextQuery setResultTransformer(ResultTransformer transformer) {
super.setResultTransformer( transformer );
@@ -884,6 +889,10 @@
return this;
}
+ protected LockOptions getLockOptions() {
+ return null;
+ }
+
public int executeUpdate() throws HibernateException {
throw new HibernateException( "Not supported operation" );
}
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java 2010-01-05 10:46:13 UTC (rev 18408)
+++ search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java 2010-01-05 10:53:42 UTC (rev 18409)
@@ -28,6 +28,7 @@
import org.hibernate.Criteria;
import org.hibernate.Session;
+import org.hibernate.context.ThreadLocalSessionContext;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.search.FullTextSession;
@@ -78,6 +79,18 @@
s.close();
}
+ public void testThreadBoundSessionWrappingOutOfTransaction() throws Exception {
+ final Session session = getSessions().getCurrentSession();
+ try {
+ FullTextSession fts = Search.getFullTextSession( session );
+ //success
+ }
+ finally {
+ //clean up after the mess
+ ThreadLocalSessionContext.unbind( getSessions() );
+ }
+ }
+
protected Class[] getMappings() {
return new Class[] {
Email.class,
@@ -90,5 +103,7 @@
// for this test we explcitly set the auto commit mode since we are not explcitly starting a transaction
// which could be a problem in some databases.
cfg.setProperty( "hibernate.connection.autocommit", "true" );
+ //needed for testThreadBoundSessionWrappingOutOfTransaction
+ cfg.setProperty( "hibernate.current_session_context_class", "thread" );
}
}
14 years, 11 months
Hibernate SVN: r18408 - core/trunk/core/src/main/java/org/hibernate/context.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-01-05 05:46:13 -0500 (Tue, 05 Jan 2010)
New Revision: 18408
Modified:
core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
Log:
HHH-4749 Don't block calls to getListeners on SessionImplementor when using thread scoped sessions
Modified: core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java 2010-01-05 09:45:30 UTC (rev 18407)
+++ core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java 2010-01-05 10:46:13 UTC (rev 18408)
@@ -311,7 +311,9 @@
|| "equals".equals( method.getName() )
|| "hashCode".equals( method.getName() )
|| "getStatistics".equals( method.getName() )
- || "isOpen".equals( method.getName() ) ) {
+ || "isOpen".equals( method.getName() )
+ || "getListeners".equals( method.getName() ) //useful for HSearch in particular
+ ) {
// allow these to go through the the real session no matter what
}
else if ( !realSession.isOpen() ) {
14 years, 11 months
Hibernate SVN: r18407 - in core/trunk/annotations/src/test/java/org/hibernate/test: annotations/override and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-01-05 04:45:30 -0500 (Tue, 05 Jan 2010)
New Revision: 18407
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/util/
core/trunk/annotations/src/test/java/org/hibernate/test/util/SchemaUtil.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/AttributeOverrideTest.java
Log:
Extract Schema helper methods
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/AttributeOverrideTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/AttributeOverrideTest.java 2010-01-05 03:18:23 UTC (rev 18406)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/AttributeOverrideTest.java 2010-01-05 09:45:30 UTC (rev 18407)
@@ -3,6 +3,7 @@
import java.util.Iterator;
import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.util.SchemaUtil;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.persister.collection.CollectionPersister;
@@ -34,20 +35,7 @@
}
public boolean isColumnPresent(String tableName, String columnName) {
- final Iterator<Table> tables = ( Iterator<Table> ) getCfg().getTableMappings();
- while (tables.hasNext()) {
- Table table = tables.next();
- if (tableName.equals( table.getName() ) ) {
- Iterator<Column> columns = (Iterator<Column>) table.getColumnIterator();
- while ( columns.hasNext() ) {
- Column column = columns.next();
- if ( columnName.equals( column.getName() ) ) {
- return true;
- }
- }
- }
- }
- return false;
+ return SchemaUtil.isColumnPresent( tableName, columnName, getCfg() );
}
protected Class<?>[] getMappings() {
Added: core/trunk/annotations/src/test/java/org/hibernate/test/util/SchemaUtil.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/util/SchemaUtil.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/util/SchemaUtil.java 2010-01-05 09:45:30 UTC (rev 18407)
@@ -0,0 +1,42 @@
+package org.hibernate.test.util;
+
+import java.util.Iterator;
+
+import org.hibernate.mapping.Table;
+import org.hibernate.mapping.Column;
+import org.hibernate.cfg.Configuration;
+
+/**
+ * Check that the Hibernate metamodel contains some database objects
+ *
+ * @author Emmanuel Bernard
+ */
+public abstract class SchemaUtil {
+ public static boolean isColumnPresent(String tableName, String columnName, Configuration cfg) {
+ final Iterator<Table> tables = ( Iterator<Table> ) cfg.getTableMappings();
+ while (tables.hasNext()) {
+ Table table = tables.next();
+ if (tableName.equals( table.getName() ) ) {
+ Iterator<Column> columns = (Iterator<Column>) table.getColumnIterator();
+ while ( columns.hasNext() ) {
+ Column column = columns.next();
+ if ( columnName.equals( column.getName() ) ) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isTablePresent(String tableName, Configuration cfg) {
+ final Iterator<Table> tables = ( Iterator<Table> ) cfg.getTableMappings();
+ while (tables.hasNext()) {
+ Table table = tables.next();
+ if (tableName.equals( table.getName() ) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
14 years, 11 months
Hibernate SVN: r18406 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy.
by hibernate-commits@lists.jboss.org
Author: smarlow(a)redhat.com
Date: 2010-01-04 22:18:23 -0500 (Mon, 04 Jan 2010)
New Revision: 18406
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
Log:
HHH-4753 Default table name for @CollectionTable is not inferred correctly according to spec requirement
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java 2010-01-05 03:16:05 UTC (rev 18405)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java 2010-01-05 03:18:23 UTC (rev 18406)
@@ -56,7 +56,7 @@
foundIt = true;
}
// make sure we use A_ADDRESS instead of AEC_address
- assertFalse("got table name mapped to: AEC_address which violates JPA-2 spec section 11.1.8 ([OWNING_ENTITY_NAME]_[COLLECTION_ATTRIBUTE_NAME])",table.getName().equalsIgnoreCase("AEC_address"));
+ assertFalse("got table name mapped to: AEC_address (should be A_ADDRESS) which violates JPA-2 spec section 11.1.8 ([OWNING_ENTITY_NAME]_[COLLECTION_ATTRIBUTE_NAME])",table.getName().equalsIgnoreCase("AEC_address"));
}
assertTrue("table not mapped to A_ADDRESS which violates JPA-2 spec section 11.1.8",foundIt);
}
14 years, 11 months
Hibernate SVN: r18405 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy.
by hibernate-commits@lists.jboss.org
Author: smarlow(a)redhat.com
Date: 2010-01-04 22:16:05 -0500 (Mon, 04 Jan 2010)
New Revision: 18405
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/A.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/AddressEntry.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
Log:
HHH-4753 Default table name for @CollectionTable is not inferred correctly according to spec requirement
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/A.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/A.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/A.java 2010-01-05 03:16:05 UTC (rev 18405)
@@ -0,0 +1,68 @@
+package org.hibernate.test.annotations.namingstrategy;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Id;
+import javax.persistence.ElementCollection;
+import javax.persistence.Column;
+import javax.persistence.JoinColumn;
+import javax.persistence.CascadeType;
+import javax.persistence.CollectionTable;
+
+@Entity
+@Table(name = "AEC")
+public class A implements java.io.Serializable {
+ @Id
+ protected String id;
+ protected String name;
+ protected int value;
+
+ @ElementCollection
+ protected Set<AddressEntry> address = new HashSet();
+
+ public A() {
+ }
+
+ public A(String id, String name, int value) {
+ this.id = id;
+ this.name = name;
+ this.value = value;
+ }
+
+ // Default to table A_AddressEntry
+ public Set<AddressEntry> getAddress() {
+ return address;
+ }
+
+ public void setAddress(Set<AddressEntry> addr) {
+ this.address = addr;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(int val) {
+ this.value = val;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/AddressEntry.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/AddressEntry.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/AddressEntry.java 2010-01-05 03:16:05 UTC (rev 18405)
@@ -0,0 +1,45 @@
+package org.hibernate.test.annotations.namingstrategy;
+
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class AddressEntry implements java.io.Serializable {
+ protected String street;
+ protected String city;
+ protected String state;
+ protected String zip;
+
+ public AddressEntry() {
+ }
+
+ public AddressEntry( String street, String city, String state, String zip) {
+ this.street = street;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ }
+ public String getCity() {
+ return city;
+ }
+ public void setCity(String c) {
+ city = c;
+ }
+ public String getState() {
+ return state;
+ }
+ public void setState(String state) {
+ this.state = state;
+ }
+ public String getStreet() {
+ return street;
+ }
+ public void setStreet(String street) {
+ this.street = street;
+ }
+ public String getZip() {
+ return zip;
+ }
+ public void setZip(String zip) {
+ this.zip = zip;
+ }
+}
\ No newline at end of file
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java 2010-01-04 20:14:42 UTC (rev 18404)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java 2010-01-05 03:16:05 UTC (rev 18405)
@@ -1,12 +1,16 @@
-// $Id:$
+// $Id$
package org.hibernate.test.annotations.namingstrategy;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.Iterator;
import junit.framework.TestCase;
import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.EJB3NamingStrategy;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.mapping.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,7 +38,36 @@
fail(e.getMessage());
}
}
-
+
+ public void testWithEJB3NamingStrategy() throws Exception {
+ try {
+ AnnotationConfiguration config = new AnnotationConfiguration();
+ config.setNamingStrategy(EJB3NamingStrategy.INSTANCE);
+ config.addAnnotatedClass(A.class);
+ config.addAnnotatedClass(AddressEntry.class);
+ config.buildSessionFactory();
+ Mappings mappings = config.createMappings();
+ boolean foundIt = false;
+
+ for ( Iterator iter = mappings.iterateTables(); iter.hasNext(); ) {
+ Table table = (Table) iter.next();
+ log.info("testWithEJB3NamingStrategy table = " + table.getName());
+ if ( table.getName().equalsIgnoreCase("A_ADDRESS")) {
+ foundIt = true;
+ }
+ // make sure we use A_ADDRESS instead of AEC_address
+ assertFalse("got table name mapped to: AEC_address which violates JPA-2 spec section 11.1.8 ([OWNING_ENTITY_NAME]_[COLLECTION_ATTRIBUTE_NAME])",table.getName().equalsIgnoreCase("AEC_address"));
+ }
+ assertTrue("table not mapped to A_ADDRESS which violates JPA-2 spec section 11.1.8",foundIt);
+ }
+ catch( Exception e ) {
+ StringWriter writer = new StringWriter();
+ e.printStackTrace(new PrintWriter(writer));
+ log.debug(writer.toString());
+ fail(e.getMessage());
+ }
+ }
+
public void testWithoutCustomNamingStrategy() throws Exception {
try {
AnnotationConfiguration config = new AnnotationConfiguration();
14 years, 11 months
Hibernate SVN: r18404 - core/trunk.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-01-04 15:14:42 -0500 (Mon, 04 Jan 2010)
New Revision: 18404
Modified:
core/trunk/
Log:
added '.idea' as svn ignore entry
Property changes on: core/trunk
___________________________________________________________________
Name: svn:ignore
- target
local
*.ipr
*.iws
*.iml
atlassian-ide-plugin.xml
.classpath
.project
.settings
.nbattrs
*.log
*.properties
.clover
+ target
local
.idea
*.ipr
*.iws
*.iml
atlassian-ide-plugin.xml
.classpath
.project
.settings
.nbattrs
*.log
*.properties
.clover
14 years, 12 months