Hibernate SVN: r19332 - in search/trunk/hibernate-search/src: test/java/org/hibernate/search/test/batchindexing and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-04-30 17:47:10 -0400 (Fri, 30 Apr 2010)
New Revision: 19332
Added:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Nation.java
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/BatchIndexingWorkspace.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AvoidDuplicatesTest.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/BatchBackendConfigurationTest.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Book.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Dvd.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/TitleAble.java
Log:
HSEARCH-512 - MassIndexer might associate proxies to two open session
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/BatchIndexingWorkspace.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/BatchIndexingWorkspace.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/BatchIndexingWorkspace.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -54,7 +54,7 @@
private final ThreadPoolExecutor execIdentifiersLoader;
private final ProducerConsumerQueue<List<Serializable>> fromIdentifierListToEntities;
private final ThreadPoolExecutor execFirstLoader;
- private final ProducerConsumerQueue<Object> fromEntityToAddwork;
+ private final ProducerConsumerQueue<List<?>> fromEntityToAddwork;
private final ThreadPoolExecutor execDocBuilding;
private final int objectLoadingThreadNum;
@@ -105,7 +105,7 @@
//pipelining queues:
this.fromIdentifierListToEntities = new ProducerConsumerQueue<List<Serializable>>( 1 );
- this.fromEntityToAddwork = new ProducerConsumerQueue<Object>( objectLoadingThreadNum );
+ this.fromEntityToAddwork = new ProducerConsumerQueue<List<?>>( objectLoadingThreadNum );
//end signal shared with other instances:
this.endAllSignal = endAllSignal;
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/EntityConsumerLuceneworkProducer.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -25,6 +25,7 @@
package org.hibernate.search.batchindexing;
import java.io.Serializable;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -54,7 +55,7 @@
private static final Logger log = LoggerFactory.make();
- private final ProducerConsumerQueue<Object> source;
+ private final ProducerConsumerQueue<List<?>> source;
private final SessionFactory sessionFactory;
private final Map<Class<?>, DocumentBuilderIndexedEntity<?>> documentBuilders;
private final MassIndexerProgressMonitor monitor;
@@ -67,7 +68,7 @@
private final BatchBackend backend;
public EntityConsumerLuceneworkProducer(
- ProducerConsumerQueue<Object> entitySource,
+ ProducerConsumerQueue<List<?>> entitySource,
MassIndexerProgressMonitor monitor,
SessionFactory sessionFactory,
CountDownLatch producerEndSignal,
@@ -91,6 +92,9 @@
indexAllQueue( session );
transaction.commit();
}
+ catch (Throwable e) {
+ log.error( "error during batch indexing: ", e );
+ }
finally {
producerEndSignal.countDown();
session.close();
@@ -101,20 +105,22 @@
private void indexAllQueue(Session session) {
try {
for ( int cycle=0; true; cycle++ ) {
- Object take = source.take();
- if ( take == null ) {
+ List<?> takeList = source.take();
+ if ( takeList == null ) {
break;
}
else {
- log.trace( "received an object {}", take );
- //trick to attach the objects to session:
- session.buildLockRequest( LockOptions.NONE ).lock( take );
- index( take, session );
- monitor.documentsBuilt( 1 );
- session.evict( take );
- if ( cycle == CLEAR_PERIOD ) {
- cycle = 0;
- session.clear();
+ log.trace( "received a list of objects to index: {}", takeList );
+ for ( Object take : takeList ) {
+ //trick to attach the objects to session:
+ session.buildLockRequest( LockOptions.NONE ).lock( take );
+ index( take, session );
+ monitor.documentsBuilt( 1 );
+ session.evict( take );
+ if ( cycle == CLEAR_PERIOD ) {
+ cycle = 0;
+ session.clear();
+ }
}
}
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/IdentifierConsumerEntityProducer.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -52,7 +52,7 @@
private static final Logger log = LoggerFactory.make();
private final ProducerConsumerQueue<List<Serializable>> source;
- private final ProducerConsumerQueue<Object> destination;
+ private final ProducerConsumerQueue<List<?>> destination;
private final SessionFactory sessionFactory;
private final CacheMode cacheMode;
private final Class<?> type;
@@ -60,7 +60,7 @@
public IdentifierConsumerEntityProducer(
ProducerConsumerQueue<List<Serializable>> fromIdentifierListToEntities,
- ProducerConsumerQueue<Object> fromEntityToAddwork,
+ ProducerConsumerQueue<List<?>> fromEntityToAddwork,
MassIndexerProgressMonitor monitor,
SessionFactory sessionFactory,
CacheMode cacheMode, Class<?> type) {
@@ -133,9 +133,7 @@
List<?> list = criteria.list();
monitor.entitiesLoaded( list.size() );
session.clear();
- for ( Object obj : list ) {
- destination.put( obj );
- }
+ destination.put( list );
}
}
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AvoidDuplicatesTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AvoidDuplicatesTest.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/AvoidDuplicatesTest.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -43,16 +43,21 @@
Session session = openSession();
Transaction transaction = session.beginTransaction();
+ Nation italy = new Nation( "Italy", "IT" );
+ session.persist( italy );
+
AncientBook aeneid = new AncientBook();
aeneid.setTitle( "Aeneid" );
aeneid.getAlternativeTitles().add( "Aeneis" );
aeneid.getAlternativeTitles().add( "Eneide" );
+ aeneid.setFirstPublishedIn( italy );
session.persist( aeneid );
AncientBook commedia = new AncientBook();
commedia.setTitle( "Commedia" );
commedia.getAlternativeTitles().add( "La Commedia" );
commedia.getAlternativeTitles().add( "La Divina Commedia" );
+ commedia.setFirstPublishedIn( italy );
session.persist( commedia );
transaction.commit();
@@ -84,7 +89,8 @@
protected Class<?>[] getMappings() {
return new Class[] {
AncientBook.class,
- Book.class
+ Book.class,
+ Nation.class
};
}
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/BatchBackendConfigurationTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/BatchBackendConfigurationTest.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/BatchBackendConfigurationTest.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -45,6 +45,7 @@
public void testConfigurationIsRead() throws InterruptedException {
FullTextSessionBuilder fsBuilder = new FullTextSessionBuilder()
.addAnnotatedClass( Book.class )
+ .addAnnotatedClass( Nation.class )
// illegal option:
.setProperty( LuceneBatchBackend.CONCURRENT_WRITERS, "0" )
.build();
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Book.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Book.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Book.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -25,11 +25,16 @@
package org.hibernate.search.test.batchindexing;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import org.hibernate.annotations.Fetch;
+import org.hibernate.annotations.FetchMode;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
@Indexed
@Entity
@@ -38,6 +43,8 @@
private long id;
private String title;
+
+ private Nation firstPublishedIn;
@Id @GeneratedValue
public long getId() {
@@ -57,4 +64,15 @@
this.title = title;
}
+ @ManyToOne(fetch=FetchType.LAZY,optional=false)
+ @Fetch(FetchMode.SELECT)
+ @IndexedEmbedded
+ public Nation getFirstPublishedIn() {
+ return firstPublishedIn;
+ }
+
+ public void setFirstPublishedIn(Nation firstPublishedIn) {
+ this.firstPublishedIn = firstPublishedIn;
+ }
+
}
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Dvd.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Dvd.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Dvd.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -25,8 +25,10 @@
package org.hibernate.search.test.batchindexing;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.ManyToOne;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
@@ -35,8 +37,9 @@
@Entity
public class Dvd implements TitleAble {
- public long unusuallyNamedIdentifier;
- public String title;
+ private long unusuallyNamedIdentifier;
+ private String title;
+ private Nation firstPublishedIn;
@Id
@GeneratedValue
@@ -56,5 +59,14 @@
public void setTitle(String title) {
this.title = title;
}
+
+ @ManyToOne(optional=false, fetch=FetchType.EAGER)
+ public Nation getFirstPublishedIn() {
+ return firstPublishedIn;
+ }
+ public void setFirstPublishedIn(Nation firstPublishedIn) {
+ this.firstPublishedIn = firstPublishedIn;
+ }
+
}
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -43,9 +43,9 @@
*/
public class IndexingGeneratedCorpusTest extends TestCase {
- private final int BOOK_NUM = 300;
- private final int ANCIENTBOOK_NUM = 60;
- private final int DVD_NUM = 200;
+ private final int BOOK_NUM = 600;
+ private final int ANCIENTBOOK_NUM = 120;
+ private final int DVD_NUM = 400;
private SentenceInventor sentenceInventor = new SentenceInventor( 7L, 10000 );
private FullTextSessionBuilder builder;
@@ -59,6 +59,7 @@
.addAnnotatedClass( Book.class )
.addAnnotatedClass( Dvd.class )
.addAnnotatedClass( AncientBook.class )
+ .addAnnotatedClass( Nation.class )
.setProperty( "hibernate.show_sql", "false" ) //too verbose for this test
.setProperty( LuceneBatchBackend.CONCURRENT_WRITERS, "4" )
.build();
@@ -76,9 +77,15 @@
FullTextSession fullTextSession = builder.openFullTextSession();
try {
Transaction tx = fullTextSession.beginTransaction();
+ fullTextSession.persist( new Nation("Italy", "IT") );
+ tx.commit();
+ tx = fullTextSession.beginTransaction();
for ( int i = 0; i < amount; i++ ) {
TitleAble instance = entityType.newInstance();
instance.setTitle( sentenceInventor.nextSentence() );
+ //to test for HSEARCH-512 we make all entities share some proxy
+ Nation country = (Nation) fullTextSession.load( Nation.class, 1 );
+ instance.setFirstPublishedIn( country );
fullTextSession.persist( instance );
totalEntitiesInDB++;
if ( i % 250 == 249 ) {
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Nation.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Nation.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/Nation.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -0,0 +1,76 @@
+/* $Id$
+ *
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, Inc.
+ *
+ * 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.search.test.batchindexing;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+
+@Entity
+public class Nation {
+
+ private Integer id;
+ private String name;
+ private String code;
+
+ public Nation() {}
+
+ public Nation(String name, String code){
+ this.name = name;
+ this.code = code;
+ }
+
+ @Id @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Field
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Field(index=Index.UN_TOKENIZED)
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+}
+
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/SearchIndexerTest.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -51,6 +51,7 @@
.addAnnotatedClass( AncientBook.class )
.addAnnotatedClass( Dvd.class )
.addAnnotatedClass( Book.class )
+ .addAnnotatedClass( Nation.class )
.build();
FullTextSession fullTextSession = ftsb.openFullTextSession();
SearchFactoryImplementor searchFactory = (SearchFactoryImplementor) fullTextSession.getSearchFactory();
@@ -106,17 +107,22 @@
FullTextSessionBuilder ftsb = new FullTextSessionBuilder()
.setProperty( org.hibernate.search.Environment.ANALYZER_CLASS, StandardAnalyzer.class.getName() )
.addAnnotatedClass( Dvd.class )
+ .addAnnotatedClass( Nation.class )
.setProperty( Environment.INDEXING_STRATEGY, "manual" )
.build();
{
//creating the test data in database only:
FullTextSession fullTextSession = ftsb.openFullTextSession();
Transaction transaction = fullTextSession.beginTransaction();
+ Nation us = new Nation( "United States of America", "US" );
+ fullTextSession.persist( us );
Dvd dvda = new Dvd();
dvda.setTitle( "Star Trek (episode 96367)" );
+ dvda.setFirstPublishedIn( us );
fullTextSession.save(dvda);
Dvd dvdb = new Dvd();
dvdb.setTitle( "The Trek" );
+ dvdb.setFirstPublishedIn( us );
fullTextSession.save(dvdb);
transaction.commit();
fullTextSession.close();
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/TitleAble.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/TitleAble.java 2010-04-30 19:33:42 UTC (rev 19331)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/TitleAble.java 2010-04-30 21:47:10 UTC (rev 19332)
@@ -29,5 +29,9 @@
public String getTitle();
public void setTitle(String title);
+
+ public void setFirstPublishedIn(Nation firstPublishedIn);
+
+ public Nation getFirstPublishedIn();
}
14 years, 7 months
Hibernate SVN: r19331 - in core/branches/Branch_3_5: core/src/main/java/org/hibernate/impl and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-04-30 15:33:42 -0400 (Fri, 30 Apr 2010)
New Revision: 19331
Modified:
core/branches/Branch_3_5/core/src/main/java/org/hibernate/cache/StandardQueryCache.java
core/branches/Branch_3_5/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
core/branches/Branch_3_5/core/src/main/java/org/hibernate/proxy/EntityNotFoundDelegate.java
core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java
Log:
HHH-3478 : StandardQueryCache.get() does not handle EntityNotFoundException for natural key lookups
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/cache/StandardQueryCache.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/cache/StandardQueryCache.java 2010-04-30 15:53:27 UTC (rev 19330)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/cache/StandardQueryCache.java 2010-04-30 19:33:42 UTC (rev 19331)
@@ -162,8 +162,10 @@
);
}
}
- catch ( UnresolvableObjectException uoe ) {
- if ( isNaturalKeyLookup ) {
+ catch ( RuntimeException ex ) {
+ if ( isNaturalKeyLookup &&
+ ( UnresolvableObjectException.class.isInstance( ex ) ||
+ session.getFactory().getEntityNotFoundDelegate().isEntityNotFoundException( ex ) ) ) {
//TODO: not really completely correct, since
// the uoe could occur while resolving
// associations, leaving the PC in an
@@ -173,7 +175,7 @@
return null;
}
else {
- throw uoe;
+ throw ex;
}
}
}
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2010-04-30 15:53:27 UTC (rev 19330)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java 2010-04-30 19:33:42 UTC (rev 19331)
@@ -446,6 +446,9 @@
public void handleEntityNotFound(String entityName, Serializable id) {
throw new ObjectNotFoundException( id, entityName );
}
+ public boolean isEntityNotFoundException(RuntimeException exception) {
+ return ObjectNotFoundException.class.isInstance( exception );
+ }
};
}
this.entityNotFoundDelegate = entityNotFoundDelegate;
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/proxy/EntityNotFoundDelegate.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/proxy/EntityNotFoundDelegate.java 2010-04-30 15:53:27 UTC (rev 19330)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/proxy/EntityNotFoundDelegate.java 2010-04-30 19:33:42 UTC (rev 19331)
@@ -33,4 +33,5 @@
*/
public interface EntityNotFoundDelegate {
public void handleEntityNotFound(String entityName, Serializable id);
+ public boolean isEntityNotFoundException(RuntimeException exception);
}
Modified: core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java 2010-04-30 15:53:27 UTC (rev 19330)
+++ core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java 2010-04-30 19:33:42 UTC (rev 19331)
@@ -70,6 +70,7 @@
import org.hibernate.Interceptor;
import org.hibernate.MappingException;
import org.hibernate.MappingNotFoundException;
+import org.hibernate.ObjectNotFoundException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
@@ -132,6 +133,9 @@
public void handleEntityNotFound(String entityName, Serializable id) {
throw new EntityNotFoundException("Unable to find " + entityName + " with id " + id);
}
+ public boolean isEntityNotFoundException(RuntimeException exception) {
+ return EntityNotFoundException.class.isInstance( exception );
+ }
}
static {
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java 2010-04-30 15:53:27 UTC (rev 19330)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java 2010-04-30 19:33:42 UTC (rev 19331)
@@ -55,6 +55,9 @@
public void handleEntityNotFound(String entityName, Serializable id) {
throw new EntityNotFoundException( entityName, id );
}
+ public boolean isEntityNotFoundException(RuntimeException exception) {
+ return EntityNotFoundException.class.isInstance( exception );
+ }
}
/**
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java 2010-04-30 15:53:27 UTC (rev 19330)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/naturalid/immutable/ImmutableNaturalIdTest.java 2010-04-30 19:33:42 UTC (rev 19331)
@@ -155,4 +155,99 @@
s.getTransaction().commit();
s.close();
}
+
+ public void testNaturalIdDeleteUsingCache() {
+ Session s = openSession();
+ s.beginTransaction();
+ User u = new User( "steve", "superSecret" );
+ s.persist( u );
+ s.getTransaction().commit();
+ s.close();
+
+ getSessions().getStatistics().clear();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId().set( "userName", "steve" ) )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNotNull( u );
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
+ assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
+ assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
+
+ getSessions().getStatistics().clear();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId().set( "userName", "steve" ) )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNotNull( u );
+ assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
+ assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
+
+ s.delete( u );
+
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId().set( "userName", "steve" ) )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNull( u );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testNaturalIdRecreateUsingCache() {
+ testNaturalIdDeleteUsingCache();
+
+ Session s = openSession();
+ s.beginTransaction();
+ User u = new User( "steve", "superSecret" );
+ s.persist( u );
+ s.getTransaction().commit();
+ s.close();
+
+ getSessions().getStatistics().clear();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId().set( "userName", "steve" ) )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNotNull( u );
+
+ assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
+ assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
+ assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
+
+ getSessions().getStatistics().clear();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId().set( "userName", "steve" ) )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNotNull( u );
+ assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
+ assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
+
+ s.delete( u );
+
+ s.getTransaction().commit();
+ s.close();
+ }
+
}
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java 2010-04-30 15:53:27 UTC (rev 19330)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java 2010-04-30 19:33:42 UTC (rev 19331)
@@ -244,6 +244,115 @@
s.close();
}
+ public void testNaturalIdDeleteUsingCache() {
+ Session s = openSession();
+ s.beginTransaction();
+ User u = new User( "steve", "hb", "superSecret" );
+ s.persist( u );
+ s.getTransaction().commit();
+ s.close();
+
+ getSessions().getStatistics().clear();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId()
+ .set("name", "steve")
+ .set("org", "hb")
+ )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNotNull( u );
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
+ assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
+ assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
+
+ getSessions().getStatistics().clear();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId()
+ .set("name", "steve")
+ .set("org", "hb")
+ )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNotNull( u );
+ assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
+ assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
+
+ s.delete( u );
+
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId()
+ .set("name", "steve")
+ .set("org", "hb")
+ )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNull( u );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testNaturalIdRecreateUsingCache() {
+ testNaturalIdDeleteUsingCache();
+
+ Session s = openSession();
+ s.beginTransaction();
+ User u = new User( "steve", "hb", "superSecret" );
+ s.persist( u );
+ s.getTransaction().commit();
+ s.close();
+
+ getSessions().getStatistics().clear();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId()
+ .set("name", "steve")
+ .set("org", "hb")
+ )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNotNull( u );
+
+ assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
+ assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
+ assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
+
+ getSessions().getStatistics().clear();
+
+ s = openSession();
+ s.beginTransaction();
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId()
+ .set("name", "steve")
+ .set("org", "hb")
+ )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNotNull( u );
+ assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
+ assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
+
+ s.delete( u );
+
+ s.getTransaction().commit();
+ s.close();
+ }
+
public void testQuerying() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
14 years, 7 months
Hibernate SVN: r19330 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-04-30 11:53:27 -0400 (Fri, 30 Apr 2010)
New Revision: 19330
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
Log:
HHH-5149 finish identifier and generator documentation
Modified: core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-04-30 15:39:28 UTC (rev 19329)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-04-30 15:53:27 UTC (rev 19330)
@@ -826,7 +826,7 @@
</section>
<section id="mapping-declaration-id" revision="4">
- <title>identifiers</title>
+ <title>Identifiers</title>
<para>Mapped classes <emphasis>must</emphasis> declare the primary key
column of the database table. Most classes will also have a
@@ -957,7 +957,7 @@
<para>Let's explore all three cases using examples.</para>
<section>
- <title>Property using a component type</title>
+ <title>id as a property using a component type</title>
<para>Here is a simple example of
<classname>@EmbeddedId</classname>.</para>
@@ -1001,6 +1001,8 @@
class CustomerId implements Serializable {
UserId userId;
String customerNumber;
+
+ //implements equals and hashCode
}
@Entity
@@ -1013,6 +1015,8 @@
class UserId implements Serializable {
String firstName;
String lastName;
+
+ //implements equals and hashCode
}</programlisting>
<para>In the embedded id object, the association is represented as
@@ -1026,6 +1030,12 @@
<literal>CustomerId.userId</literal> properties share the same
underlying column (<literal>user_fk</literal> in this case).</para>
+ <tip>
+ <para>The component type used as identifier must implement
+ <methodname>equals()</methodname> and
+ <methodname>hashCode()</methodname>.</para>
+ </tip>
+
<para>In practice, your code only sets the
<literal>Customer.user</literal> property and the user id value is
copied by Hibernate into the <literal>CustomerId.userId</literal>
@@ -1055,6 +1065,8 @@
})
User user;
String customerNumber;
+
+ //implements equals and hashCode
}
@Entity
@@ -1067,10 +1079,13 @@
class UserId implements Serializable {
String firstName;
String lastName;
+
+
+ //implements equals and hashCode
}</programlisting>
- <para>Let's now rewrite these examples using the hbm.xml syntax.
- </para>
+ <para>Let's now rewrite these examples using the hbm.xml
+ syntax.</para>
<programlisting role="XML"><composite-id
name="propertyName"
@@ -1157,11 +1172,6 @@
</composite-id>
<property name="preferredCustomer"/>
-
- <many-to-one name="user">
- <column name="userfirstname_fk" updatable="false" insertable="false"/>
- <column name="userlastname_fk" updatable="false" insertable="false"/>
- </many-to-one>
</class>
<class name="User">
@@ -1172,51 +1182,83 @@
<property name="age"/>
</class></programlisting>
+
+ <para>This is the recommended approach to map composite identifier.
+ The following options should not be considered unless some
+ constraint are present.</para>
</section>
<section>
- <title>Multiple @Id properties</title>
+ <title>Multiple id properties without identifier type</title>
- <para>XXXXXXXXXXXXXXXXXXXXXXXXXXXXX</para>
-
<para>Another, arguably more natural, approach is to place
- <classname>@Id</classname> on multiple properties of my entity. This
- approach is only supported by Hibernate but does not require an
- extra embeddable component.</para>
+ <classname>@Id</classname> on multiple properties of your entity.
+ This approach is only supported by Hibernate (not JPA compliant) but
+ does not require an extra embeddable component.</para>
<programlisting language="JAVA" role="JAVA">@Entity
class Customer implements Serializable {
- @Id @OneToOne
- @JoinColumns({
- @JoinColumn(name="userfirstname_fk", referencedColumnName="firstName"),
- @JoinColumn(name="userlastname_fk", referencedColumnName="lastName")
- })
- User user;
+ @Id @OneToOne
+ @JoinColumns({
+ @JoinColumn(name="userfirstname_fk", referencedColumnName="firstName"),
+ @JoinColumn(name="userlastname_fk", referencedColumnName="lastName")
+ })
+ User user;
- @Id String customerNumber;
+ @Id String customerNumber;
- boolean preferredCustomer;
+ boolean preferredCustomer;
+
+ //implements equals and hashCode
}
@Entity
class User {
- @EmbeddedId UserId id;
- Integer age;
+ @EmbeddedId UserId id;
+ Integer age;
}
@Embeddable
class UserId implements Serializable {
- String firstName;
- String lastName;
+ String firstName;
+ String lastName;
+
+ //implements equals and hashCode
}</programlisting>
- <para>In this case <classname>Customer</classname> being it's own
- identifier representation, it must implement
- <classname>Serializable</classname>.</para>
+ <para>In this case <classname>Customer</classname> is its own
+ identifier representation: it must implement
+ <classname>Serializable</classname> and must implement
+ <methodname>equals()</methodname> and
+ <methodname>hashCode()</methodname>.</para>
+
+ <para>In hbm.xml, the same mapping is:</para>
+
+ <programlisting role="XML"><class name="Customer">
+ <composite-id>
+ <key-many-to-one name="user">
+ <column name="userfirstname_fk"/>
+ <column name="userlastname_fk"/>
+ </key-many-to-one>
+ <key-property name="customerNumber"/>
+ </composite-id>
+
+ <property name="preferredCustomer"/>
+</class>
+
+<class name="User">
+ <composite-id name="id" class="UserId">
+ <key-property name="firstName"/>
+ <key-property name="lastName"/>
+ </composite-id>
+
+ <property name="age"/>
+</class></programlisting>
</section>
<section>
- <title>@IdClass</title>
+ <title>Multiple id properties with with a dedicated identifier
+ type</title>
<para><classname>@IdClass</classname> on an entity points to the
class (component) representing the identifier of the class. The
@@ -1233,68 +1275,83 @@
</warning>
<programlisting language="JAVA" role="JAVA">@Entity
-class Customer {
- @Id @OneToOne
- @JoinColumns({
- @JoinColumn(name="userfirstname_fk", referencedColumnName="firstName"),
- @JoinColumn(name="userlastname_fk", referencedColumnName="lastName")
- })
- User user;
+(a)IdClass(CustomerId.class)
+class Customer implements Serializable {
+ @Id @OneToOne
+ @JoinColumns({
+ @JoinColumn(name="userfirstname_fk", referencedColumnName="firstName"),
+ @JoinColumn(name="userlastname_fk", referencedColumnName="lastName")
+ })
+ User user;
- @Id String customerNumber;
+ @Id String customerNumber;
- boolean preferredCustomer;
+ boolean preferredCustomer;
}
class CustomerId implements Serializable {
- UserId user;
- String customerNumber;
+ UserId user;
+ String customerNumber;
+
+ //implements equals and hashCode
}
@Entity
class User {
- @EmbeddedId UserId id;
- Integer age;
+ @EmbeddedId UserId id;
+ Integer age;
+
+ //implements equals and hashCode
}
@Embeddable
class UserId implements Serializable {
- String firstName;
- String lastName;
+ String firstName;
+ String lastName;
+
+ //implements equals and hashCode
}</programlisting>
<para><classname>Customer</classname> and
<classname>CustomerId</classname> do have the same properties
<literal>customerNumber</literal> as well as
- <literal>user</literal>.</para>
+ <literal>user</literal>. <classname>CustomerId</classname> must be
+ <classname>Serializable</classname> and implement
+ <classname>equals()</classname> and
+ <classname>hashCode()</classname>.</para>
<para>While not JPA standard, Hibernate let's you declare the
vanilla associated property in the
<classname>@IdClass</classname>.</para>
<programlisting language="JAVA" role="JAVA">@Entity
-class Customer {
- @Id @OneToOne
- @JoinColumns({
- @JoinColumn(name="userfirstname_fk", referencedColumnName="firstName"),
- @JoinColumn(name="userlastname_fk", referencedColumnName="lastName")
- })
- User user;
+(a)IdClass(CustomerId.class)
+class Customer implements Serializable {
+ @Id @OneToOne
+ @JoinColumns({
+ @JoinColumn(name="userfirstname_fk", referencedColumnName="firstName"),
+ @JoinColumn(name="userlastname_fk", referencedColumnName="lastName")
+ })
+ User user;
- @Id String customerNumber;
+ @Id String customerNumber;
- boolean preferredCustomer;
+ boolean preferredCustomer;
}
class CustomerId implements Serializable {
- @OneToOne User user;
- String customerNumber;
+ @OneToOne User user;
+ String customerNumber;
+
+ //implements equals and hashCode
}
@Entity
class User {
- @EmbeddedId UserId id;
- Integer age;
+ @EmbeddedId UserId id;
+ Integer age;
+
+ //implements equals and hashCode
}
@Embeddable
@@ -1302,59 +1359,267 @@
String firstName;
String lastName;
}</programlisting>
+
+ <para>This feature is of limited interest though as you are likely
+ to have chosen the <classname>@IdClass</classname> approach to stay
+ JPA compliant or you have a quite twisted mind.</para>
+
+ <para>Here are the equivalent on hbm.xml files:</para>
+
+ <programlisting role="XML"><class name="Customer">
+ <composite-id class="CustomerId" mapped="true">
+ <key-many-to-one name="user">
+ <column name="userfirstname_fk"/>
+ <column name="userlastname_fk"/>
+ </key-many-to-one>
+ <key-property name="customerNumber"/>
+ </composite-id>
+
+ <property name="preferredCustomer"/>
+</class>
+
+<class name="User">
+ <composite-id name="id" class="UserId">
+ <key-property name="firstName"/>
+ <key-property name="lastName"/>
+ </composite-id>
+
+ <property name="age"/>
+</class></programlisting>
</section>
+ </section>
- <section>
- <title>Partial identifier generation</title>
+ <section id="mapping-declaration-id-generator" revision="2">
+ <title>Identifier generator</title>
- <para>Hibernate supports the automatic generation of some of the
- identifier properties. Simply use the
- <classname>@GeneratedValue</classname> annotation on one or several
- id properties.</para>
+ <para>Hibernate can generate and populate identifier values for you
+ automatically. This is the recommended approach over "business" or
+ "natural" id (especially composite ids).</para>
- <warning>
- <para>The Hibernate team has always felt such a construct as
- fundamentally wrong. Try hard to fix your data model before using
- this feature.</para>
- </warning>
+ <para>Hibernate offers various generation strategies, let's explore
+ the most common ones first that happens to be standardized by
+ JPA:</para>
- <programlisting language="JAVA" role="JAVA">@Entity
-public class CustomerInventory implements Serializable {
- @Id
- @TableGenerator(name = "inventory",
- table = "U_SEQUENCES",
- pkColumnName = "S_ID",
- valueColumnName = "S_NEXTNUM",
- pkColumnValue = "inventory",
- allocationSize = 1000)
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "inventory")
- Integer id;
+ <itemizedlist>
+ <listitem>
+ <para>IDENTITY: supports identity columns in DB2, MySQL, MS SQL
+ Server, Sybase and HypersonicSQL. The returned identifier is of
+ type <literal>long</literal>, <literal>short</literal> or
+ <literal>int</literal>.</para>
+ </listitem>
+ <listitem>
+ <para>SEQUENCE (called <literal>seqhilo</literal> in Hibernate):
+ uses a hi/lo algorithm to efficiently generate identifiers of type
+ <literal>long</literal>, <literal>short</literal> or
+ <literal>int</literal>, given a named database sequence.</para>
+ </listitem>
- @Id @ManyToOne(cascade = CascadeType.MERGE)
- Customer customer;
+ <listitem>
+ <para>TABLE (called
+ <classname>MultipleHiLoPerTableGenerator</classname> in Hibernate)
+ : uses a hi/lo algorithm to efficiently generate identifiers of
+ type <literal>long</literal>, <literal>short</literal> or
+ <literal>int</literal>, given a table and column as a source of hi
+ values. The hi/lo algorithm generates identifiers that are unique
+ only for a particular database.</para>
+ </listitem>
+
+ <listitem>
+ <para>AUTO: selects <literal>IDENTITY</literal>,
+ <literal>SEQUENCE</literal> or <literal>TABLE</literal> depending
+ upon the capabilities of the underlying database.</para>
+ </listitem>
+ </itemizedlist>
+
+ <important>
+ <para>We recommend all new projects to use the new enhanced
+ identifier generators. They are deactivated by default for entities
+ using annotations but can be activated using
+ <code>hibernate.id.new_generator_mappings=true</code>. These new
+ generators are more efficient and closer to the JPA 2 specification
+ semantic.</para>
+
+ <para>However they are not backward compatible with existing
+ Hibernate based application (if a sequence or a table is used for id
+ generation). See XXXXXXX <xref linkend="ann-setup-properties" /> for
+ more information on how to activate them.</para>
+ </important>
+
+ <para>To mark an id property as generated, use the
+ <classname>@GeneratedValue</classname> annotation. You can specify the
+ strategy used (default to <literal>AUTO</literal>) by setting
+ <literal>strategy</literal>.</para>
+
+ <programlisting role="JAVA">@Entity
+public class Customer {
+ @Id @GeneratedValue
+ Integer getId() { ... };
}
-@Entity
-public class Customer implements Serializable {
- @Id
- private int id;
+@Entity
+public class Invoice {
+ @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
+ Integer getId() { ... };
}</programlisting>
- <para>You can also generate properties inside an
- <classname>@EmbeddedId</classname> class.</para>
- </section>
- </section>
+ <para><literal>SEQUENCE</literal> and <literal>TABLE</literal> require
+ additional configurations that you can set using
+ <classname>@SequenceGenerator</classname> and
+ <classname>@TableGenerator</classname>:</para>
- <section id="mapping-declaration-id-generator" revision="2">
- <title>Generator</title>
+ <itemizedlist>
+ <listitem>
+ <para><literal>name</literal>: name of the generator</para>
+ </listitem>
- <para>The optional <literal><generator></literal> child element
- names a Java class used to generate unique identifiers for instances
- of the persistent class. If any parameters are required to configure
- or initialize the generator instance, they are passed using the
- <literal><param></literal> element.</para>
+ <listitem>
+ <para><literal>table</literal> / <literal>sequenceName</literal>:
+ name of the table or the sequence (defaulting respectively to
+ <literal>hibernate_sequences</literal> and
+ <literal>hibernate_sequence</literal>)</para>
+ </listitem>
+ <listitem>
+ <para><literal>catalog</literal> /
+ <literal>schema</literal>:</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>initialValue</literal>: the value from which the id
+ is to start generating</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>allocationSize</literal>: the amount to increment
+ by when allocating id numbers from the generator</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>In addition, the <classname>TABLE</classname> strategy also let
+ you customize:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><literal>pkColumnName</literal>: the column name containing
+ the entity identifier</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>valueColumnName</literal>: the column name
+ containing the identifier value</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>pkColumnValue</literal>: the entity
+ identifier</para>
+ </listitem>
+
+ <listitem>
+ <para><literal>uniqueConstraints</literal>: any potential column
+ constraint on the table containing the ids</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>To link a table or sequence generator definition with an actual
+ generated property, use the same name in both the definition
+ <literal>name</literal> and the generator value
+ <literal>generator</literal> as shown below.</para>
+
+ <programlisting language="JAVA" role="JAVA">@Id
+@GeneratedValue(
+ strategy=GenerationType.SEQUENCE,
+ generator="SEQ_GEN")
+(a)javax.persistence.SequenceGenerator(
+ name="SEQ_GEN",
+ sequenceName="my_sequence",
+ allocationSize=20
+)
+public Integer getId() { ... } </programlisting>
+
+ <para>The scope of a generator definitioncan be the application or the
+ class. Class-defined generators are not visible outside the class and
+ can override application level generators. Application level
+ generators are defined in JPA's XML deployment descriptors (see XXXXXX
+ <xref linkend="xml-overriding" />):</para>
+
+ <programlisting language="JAVA" role="JAVA"><table-generator name="EMP_GEN"
+ table="GENERATOR_TABLE"
+ pk-column-name="key"
+ value-column-name="hi"
+ pk-column-value="EMP"
+ allocation-size="20"/>
+
+//and the annotation equivalent
+
+(a)javax.persistence.TableGenerator(
+ name="EMP_GEN",
+ table="GENERATOR_TABLE",
+ pkColumnName = "key",
+ valueColumnName = "hi"
+ pkColumnValue="EMP",
+ allocationSize=20
+)
+
+<sequence-generator name="SEQ_GEN"
+ sequence-name="my_sequence"
+ allocation-size="20"/>
+
+//and the annotation equivalent
+
+(a)javax.persistence.SequenceGenerator(
+ name="SEQ_GEN",
+ sequenceName="my_sequence",
+ allocationSize=20
+)
+ </programlisting>
+
+ <para>If a JPA XML descriptor (like
+ <filename>META-INF/orm.xml</filename>) is used to define the
+ generators, <literal>EMP_GEN</literal> and <literal>SEQ_GEN</literal>
+ are application level generators.</para>
+
+ <note>
+ <para>Package level definition is not supported by the JPA
+ specification. However, you can use the
+ <literal>@GenericGenerator</literal> at the package level (see <xref
+ linkend="entity-hibspec-identifier" />).</para>
+ </note>
+
+ <para>These are the four standard JPA generators. Hibernate goes
+ beyond that and provide additional generators or additional options as
+ we will see below. You can also write your own custom identifier
+ generator by implementing
+ <classname>org.hibernate.id.IdentifierGenerator</classname>.</para>
+
+ <para>To define a custom generator, use the
+ <classname>@GenericGenerator</classname> annotation (and its plural
+ counter part <classname>@GenericGenerators</classname>) that describes
+ the class of the identifier generator or its short cut name (as
+ described below) and a list of key/value parameters. When using
+ <classname>@GenericGenerator</classname> and assigning it via
+ <classname>@GeneratedValue.generator</classname>, the
+ <classname>@GeneratedValue.strategy</classname> is ignored: leave it
+ blank.</para>
+
+ <programlisting language="JAVA" role="JAVA">@Id @GeneratedValue(generator="system-uuid")
+@GenericGenerator(name="system-uuid", strategy = "uuid")
+public String getId() {
+
+@Id @GeneratedValue(generator="trigger-generated")
+@GenericGenerator(
+ name="trigger-generated",
+ strategy = "select",
+ parameters = @Parameter(name="key", value = "socialSecurityNumber")
+)
+public String getId() {</programlisting>
+
+ <para>The hbm.xml approach uses the optional
+ <literal><generator></literal> child element inside
+ <literal><id></literal>. If any parameters are required to
+ configure or initialize the generator instance, they are passed using
+ the <literal><param></literal> element.</para>
+
<programlisting role="XML"><id name="id" type="long" column="cat_id">
<generator class="org.hibernate.id.TableHiLoGenerator">
<param name="table">uid_table</param>
@@ -1362,163 +1627,167 @@
</generator>
</id></programlisting>
- <para>All generators implement the interface
- <literal>org.hibernate.id.IdentifierGenerator</literal>. This is a
- very simple interface. Some applications can choose to provide their
- own specialized implementations, however, Hibernate provides a range
- of built-in implementations. The shortcut names for the built-in
- generators are as follows: <variablelist>
- <varlistentry>
- <term><literal>increment</literal></term>
+ <section>
+ <title>Various additional generators</title>
- <listitem>
- <para>generates identifiers of type <literal>long</literal>,
- <literal>short</literal> or <literal>int</literal> that are
- unique only when no other process is inserting data into the
- same table. <emphasis>Do not use in a
- cluster.</emphasis></para>
- </listitem>
- </varlistentry>
+ <para>All generators implement the interface
+ <literal>org.hibernate.id.IdentifierGenerator</literal>. This is a
+ very simple interface. Some applications can choose to provide their
+ own specialized implementations, however, Hibernate provides a range
+ of built-in implementations. The shortcut names for the built-in
+ generators are as follows: <variablelist>
+ <varlistentry>
+ <term><literal>increment</literal></term>
- <varlistentry>
- <term><literal>identity</literal></term>
+ <listitem>
+ <para>generates identifiers of type <literal>long</literal>,
+ <literal>short</literal> or <literal>int</literal> that are
+ unique only when no other process is inserting data into the
+ same table. <emphasis>Do not use in a
+ cluster.</emphasis></para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>supports identity columns in DB2, MySQL, MS SQL Server,
- Sybase and HypersonicSQL. The returned identifier is of type
- <literal>long</literal>, <literal>short</literal> or
- <literal>int</literal>.</para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>identity</literal></term>
- <varlistentry>
- <term><literal>sequence</literal></term>
+ <listitem>
+ <para>supports identity columns in DB2, MySQL, MS SQL
+ Server, Sybase and HypersonicSQL. The returned identifier is
+ of type <literal>long</literal>, <literal>short</literal> or
+ <literal>int</literal>.</para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>uses a sequence in DB2, PostgreSQL, Oracle, SAP DB,
- McKoi or a generator in Interbase. The returned identifier is
- of type <literal>long</literal>, <literal>short</literal> or
- <literal>int</literal></para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>sequence</literal></term>
- <varlistentry>
- <term><literal>hilo</literal></term>
+ <listitem>
+ <para>uses a sequence in DB2, PostgreSQL, Oracle, SAP DB,
+ McKoi or a generator in Interbase. The returned identifier
+ is of type <literal>long</literal>, <literal>short</literal>
+ or <literal>int</literal></para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para id="mapping-declaration-id-hilodescription"
- revision="1">uses a hi/lo algorithm to efficiently generate
- identifiers of type <literal>long</literal>,
- <literal>short</literal> or <literal>int</literal>, given a
- table and column (by default
- <literal>hibernate_unique_key</literal> and
- <literal>next_hi</literal> respectively) as a source of hi
- values. The hi/lo algorithm generates identifiers that are
- unique only for a particular database.</para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>hilo</literal></term>
- <varlistentry>
- <term><literal>seqhilo</literal></term>
+ <listitem>
+ <para id="mapping-declaration-id-hilodescription"
+ revision="1">uses a hi/lo algorithm to efficiently generate
+ identifiers of type <literal>long</literal>,
+ <literal>short</literal> or <literal>int</literal>, given a
+ table and column (by default
+ <literal>hibernate_unique_key</literal> and
+ <literal>next_hi</literal> respectively) as a source of hi
+ values. The hi/lo algorithm generates identifiers that are
+ unique only for a particular database.</para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>uses a hi/lo algorithm to efficiently generate
- identifiers of type <literal>long</literal>,
- <literal>short</literal> or <literal>int</literal>, given a
- named database sequence.</para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>seqhilo</literal></term>
- <varlistentry>
- <term><literal>uuid</literal></term>
+ <listitem>
+ <para>uses a hi/lo algorithm to efficiently generate
+ identifiers of type <literal>long</literal>,
+ <literal>short</literal> or <literal>int</literal>, given a
+ named database sequence.</para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>uses a 128-bit UUID algorithm to generate identifiers of
- type string that are unique within a network (the IP address
- is used). The UUID is encoded as a string of 32 hexadecimal
- digits in length.</para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>uuid</literal></term>
- <varlistentry>
- <term><literal>guid</literal></term>
+ <listitem>
+ <para>uses a 128-bit UUID algorithm to generate identifiers
+ of type string that are unique within a network (the IP
+ address is used). The UUID is encoded as a string of 32
+ hexadecimal digits in length.</para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>uses a database-generated GUID string on MS SQL Server
- and MySQL.</para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>guid</literal></term>
- <varlistentry>
- <term><literal>native</literal></term>
+ <listitem>
+ <para>uses a database-generated GUID string on MS SQL Server
+ and MySQL.</para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>selects <literal>identity</literal>,
- <literal>sequence</literal> or <literal>hilo</literal>
- depending upon the capabilities of the underlying
- database.</para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>native</literal></term>
- <varlistentry>
- <term><literal>assigned</literal></term>
+ <listitem>
+ <para>selects <literal>identity</literal>,
+ <literal>sequence</literal> or <literal>hilo</literal>
+ depending upon the capabilities of the underlying
+ database.</para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>lets the application assign an identifier to the object
- before <literal>save()</literal> is called. This is the
- default strategy if no <literal><generator></literal>
- element is specified.</para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>assigned</literal></term>
- <varlistentry>
- <term><literal>select</literal></term>
+ <listitem>
+ <para>lets the application assign an identifier to the
+ object before <literal>save()</literal> is called. This is
+ the default strategy if no
+ <literal><generator></literal> element is
+ specified.</para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>retrieves a primary key, assigned by a database trigger,
- by selecting the row by some unique key and retrieving the
- primary key value.</para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>select</literal></term>
- <varlistentry>
- <term><literal>foreign</literal></term>
+ <listitem>
+ <para>retrieves a primary key, assigned by a database
+ trigger, by selecting the row by some unique key and
+ retrieving the primary key value.</para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>uses the identifier of another associated object. It is
- usually used in conjunction with a
- <literal><one-to-one></literal> primary key
- association.</para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><literal>foreign</literal></term>
- <varlistentry>
- <term><literal>sequence-identity</literal></term>
+ <listitem>
+ <para>uses the identifier of another associated object. It
+ is usually used in conjunction with a
+ <literal><one-to-one></literal> primary key
+ association.</para>
+ </listitem>
+ </varlistentry>
- <listitem>
- <para>a specialized sequence generation strategy that utilizes
- a database sequence for the actual value generation, but
- combines this with JDBC3 getGeneratedKeys to return the
- generated identifier value as part of the insert statement
- execution. This strategy is only supported on Oracle 10g
- drivers targeted for JDK 1.4. Comments on these insert
- statements are disabled due to a bug in the Oracle
- drivers.</para>
- </listitem>
- </varlistentry>
- </variablelist></para>
- </section>
+ <varlistentry>
+ <term><literal>sequence-identity</literal></term>
- <section id="mapping-declaration-id-hilo" revision="1">
- <title>Hi/lo algorithm</title>
+ <listitem>
+ <para>a specialized sequence generation strategy that
+ utilizes a database sequence for the actual value
+ generation, but combines this with JDBC3 getGeneratedKeys to
+ return the generated identifier value as part of the insert
+ statement execution. This strategy is only supported on
+ Oracle 10g drivers targeted for JDK 1.4. Comments on these
+ insert statements are disabled due to a bug in the Oracle
+ drivers.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist></para>
+ </section>
- <para>The <literal>hilo</literal> and <literal>seqhilo</literal>
- generators provide two alternate implementations of the hi/lo
- algorithm. The first implementation requires a "special" database
- table to hold the next available "hi" value. Where supported, the
- second uses an Oracle-style sequence.</para>
+ <section id="mapping-declaration-id-hilo" revision="1">
+ <title>Hi/lo algorithm</title>
- <programlisting role="XML"><id name="id" type="long" column="cat_id">
+ <para>The <literal>hilo</literal> and <literal>seqhilo</literal>
+ generators provide two alternate implementations of the hi/lo
+ algorithm. The first implementation requires a "special" database
+ table to hold the next available "hi" value. Where supported, the
+ second uses an Oracle-style sequence.</para>
+
+ <programlisting role="XML"><id name="id" type="long" column="cat_id">
<generator class="hilo">
<param name="table">hi_value</param>
<param name="column">next_value</param>
@@ -1526,373 +1795,363 @@
</generator>
</id></programlisting>
- <programlisting role="XML"><id name="id" type="long" column="cat_id">
+ <programlisting role="XML"><id name="id" type="long" column="cat_id">
<generator class="seqhilo">
<param name="sequence">hi_value</param>
<param name="max_lo">100</param>
</generator>
</id></programlisting>
- <para>Unfortunately, you cannot use <literal>hilo</literal> when
- supplying your own <literal>Connection</literal> to Hibernate. When
- Hibernate uses an application server datasource to obtain connections
- enlisted with JTA, you must configure the
- <literal>hibernate.transaction.manager_lookup_class</literal>.</para>
- </section>
+ <para>Unfortunately, you cannot use <literal>hilo</literal> when
+ supplying your own <literal>Connection</literal> to Hibernate. When
+ Hibernate uses an application server datasource to obtain
+ connections enlisted with JTA, you must configure the
+ <literal>hibernate.transaction.manager_lookup_class</literal>.</para>
+ </section>
- <section id="mapping-declaration-id-uuid">
- <title>UUID algorithm</title>
+ <section id="mapping-declaration-id-uuid">
+ <title>UUID algorithm</title>
- <para>The UUID contains: IP address, startup time of the JVM that is
- accurate to a quarter second, system time and a counter value that is
- unique within the JVM. It is not possible to obtain a MAC address or
- memory address from Java code, so this is the best option without
- using JNI.</para>
- </section>
+ <para>The UUID contains: IP address, startup time of the JVM that is
+ accurate to a quarter second, system time and a counter value that
+ is unique within the JVM. It is not possible to obtain a MAC address
+ or memory address from Java code, so this is the best option without
+ using JNI.</para>
+ </section>
- <section id="mapping-declaration-id-sequences">
- <title>Identity columns and sequences</title>
+ <section id="mapping-declaration-id-sequences">
+ <title>Identity columns and sequences</title>
- <para>For databases that support identity columns (DB2, MySQL, Sybase,
- MS SQL), you can use <literal>identity</literal> key generation. For
- databases that support sequences (DB2, Oracle, PostgreSQL, Interbase,
- McKoi, SAP DB) you can use <literal>sequence</literal> style key
- generation. Both of these strategies require two SQL queries to insert
- a new object. For example:</para>
+ <para>For databases that support identity columns (DB2, MySQL,
+ Sybase, MS SQL), you can use <literal>identity</literal> key
+ generation. For databases that support sequences (DB2, Oracle,
+ PostgreSQL, Interbase, McKoi, SAP DB) you can use
+ <literal>sequence</literal> style key generation. Both of these
+ strategies require two SQL queries to insert a new object. For
+ example:</para>
- <programlisting role="XML"><id name="id" type="long" column="person_id">
+ <programlisting role="XML"><id name="id" type="long" column="person_id">
<generator class="sequence">
<param name="sequence">person_id_sequence</param>
</generator>
</id></programlisting>
- <programlisting role="XML"><id name="id" type="long" column="person_id" unsaved-value="0">
+ <programlisting role="XML"><id name="id" type="long" column="person_id" unsaved-value="0">
<generator class="identity"/>
</id></programlisting>
- <para>For cross-platform development, the <literal>native</literal>
- strategy will, depending on the capabilities of the underlying
- database, choose from the <literal>identity</literal>,
- <literal>sequence</literal> and <literal>hilo</literal>
- strategies.</para>
- </section>
+ <para>For cross-platform development, the <literal>native</literal>
+ strategy will, depending on the capabilities of the underlying
+ database, choose from the <literal>identity</literal>,
+ <literal>sequence</literal> and <literal>hilo</literal>
+ strategies.</para>
+ </section>
- <section id="mapping-declaration-id-assigned">
- <title>Assigned identifiers</title>
+ <section id="mapping-declaration-id-assigned">
+ <title>Assigned identifiers</title>
- <para>If you want the application to assign identifiers, as opposed to
- having Hibernate generate them, you can use the
- <literal>assigned</literal> generator. This special generator uses the
- identifier value already assigned to the object's identifier property.
- The generator is used when the primary key is a natural key instead of
- a surrogate key. This is the default behavior if you do not specify a
- <literal><generator></literal> element.</para>
+ <para>If you want the application to assign identifiers, as opposed
+ to having Hibernate generate them, you can use the
+ <literal>assigned</literal> generator. This special generator uses
+ the identifier value already assigned to the object's identifier
+ property. The generator is used when the primary key is a natural
+ key instead of a surrogate key. This is the default behavior if you
+ do not specify <classname>@GeneratedValue</classname> nor
+ <literal><generator></literal> elements.</para>
- <para>The <literal>assigned</literal> generator makes Hibernate use
- <literal>unsaved-value="undefined"</literal>. This forces Hibernate to
- go to the database to determine if an instance is transient or
- detached, unless there is a version or timestamp property, or you
- define <literal>Interceptor.isUnsaved()</literal>.</para>
- </section>
+ <para>The <literal>assigned</literal> generator makes Hibernate use
+ <literal>unsaved-value="undefined"</literal>. This forces Hibernate
+ to go to the database to determine if an instance is transient or
+ detached, unless there is a version or timestamp property, or you
+ define <literal>Interceptor.isUnsaved()</literal>.</para>
+ </section>
- <section id="mapping-declaration-id-select">
- <title>Primary keys assigned by triggers</title>
+ <section id="mapping-declaration-id-select">
+ <title>Primary keys assigned by triggers</title>
- <para>Hibernate does not generate DDL with triggers. It is for legacy
- schemas only.</para>
+ <para>Hibernate does not generate DDL with triggers. It is for
+ legacy schemas only.</para>
- <programlisting role="XML"><id name="id" type="long" column="person_id">
+ <programlisting role="XML"><id name="id" type="long" column="person_id">
<generator class="select">
<param name="key">socialSecurityNumber</param>
</generator>
</id></programlisting>
- <para>In the above example, there is a unique valued property named
- <literal>socialSecurityNumber</literal>. It is defined by the class,
- as a natural key and a surrogate key named
- <literal>person_id</literal>, whose value is generated by a
- trigger.</para>
- </section>
- </section>
+ <para>In the above example, there is a unique valued property named
+ <literal>socialSecurityNumber</literal>. It is defined by the class,
+ as a natural key and a surrogate key named
+ <literal>person_id</literal>, whose value is generated by a
+ trigger.</para>
+ </section>
- <section id="mapping-declaration-id-enhanced">
- <title>Enhanced identifier generators</title>
+ <section>
+ <title>Identity copy (foreign generator)</title>
- <para>Starting with release 3.2.3, there are 2 new generators which
- represent a re-thinking of 2 different aspects of identifier generation.
- The first aspect is database portability; the second is optimization
- Optimization means that you do not have to query the database for every
- request for a new identifier value. These two new generators are
- intended to take the place of some of the named generators described
- above, starting in 3.3.x. However, they are included in the current
- releases and can be referenced by FQN.</para>
+ <para>Finally, you can ask Hibernate to copy the identifier from
+ another associated entity. In the Hibernate jargon, it is known as a
+ foreign generator but the JPA mapping reads better and is
+ encouraged.</para>
- <para>The first of these new generators is
- <literal>org.hibernate.id.enhanced.SequenceStyleGenerator</literal>
- which is intended, firstly, as a replacement for the
- <literal>sequence</literal> generator and, secondly, as a better
- portability generator than <literal>native</literal>. This is because
- <literal>native</literal> generally chooses between
- <literal>identity</literal> and <literal>sequence</literal> which have
- largely different semantics that can cause subtle issues in applications
- eyeing portability.
- <literal>org.hibernate.id.enhanced.SequenceStyleGenerator</literal>,
- however, achieves portability in a different manner. It chooses between
- a table or a sequence in the database to store its incrementing values,
- depending on the capabilities of the dialect being used. The difference
- between this and <literal>native</literal> is that table-based and
- sequence-based storage have the same exact semantic. In fact, sequences
- are exactly what Hibernate tries to emulate with its table-based
- generators. This generator has a number of configuration parameters:
- <itemizedlist spacing="compact">
- <listitem>
- <para><literal>sequence_name</literal> (optional, defaults to
- <literal>hibernate_sequence</literal>): the name of the sequence
- or table to be used.</para>
- </listitem>
+ <programlisting language="JAVA" role="JAVA">@Entity
+class MedicalHistory implements Serializable {
+ @Id @OneToOne
+ @JoinColumn(name = "person_id")
+ Person patient;
+}
- <listitem>
- <para><literal>initial_value</literal> (optional, defaults to
- <literal>1</literal>): the initial value to be retrieved from the
- sequence/table. In sequence creation terms, this is analogous to
- the clause typically named "STARTS WITH".</para>
- </listitem>
+@Entity
+public class Person implements Serializable {
+ @Id @GeneratedValue Integer id;
+}</programlisting>
- <listitem>
- <para><literal>increment_size</literal> (optional - defaults to
- <literal>1</literal>): the value by which subsequent calls to the
- sequence/table should differ. In sequence creation terms, this is
- analogous to the clause typically named "INCREMENT BY".</para>
- </listitem>
+ <para>Or alternatively</para>
- <listitem>
- <para><literal>force_table_use</literal> (optional - defaults to
- <literal>false</literal>): should we force the use of a table as
- the backing structure even though the dialect might support
- sequence?</para>
- </listitem>
+ <programlisting language="JAVA" role="JAVA">@Entity
+class MedicalHistory implements Serializable {
+ @Id Integer id;
- <listitem>
- <para><literal>value_column</literal> (optional - defaults to
- <literal>next_val</literal>): only relevant for table structures,
- it is the name of the column on the table which is used to hold
- the value.</para>
- </listitem>
+ @MapsId @OneToOne
+ @JoinColumn(name = "patient_id")
+ Person patient;
+}
- <listitem>
- <para><literal>optimizer</literal> (optional - defaults to
- <literal>none</literal>): See <xref
- linkend="mapping-declaration-id-enhanced-optimizers" /></para>
- </listitem>
- </itemizedlist></para>
+@Entity
+class Person {
+ @Id @GeneratedValue Integer id;
+}</programlisting>
- <para>The second of these new generators is
- <literal>org.hibernate.id.enhanced.TableGenerator</literal>, which is
- intended, firstly, as a replacement for the <literal>table</literal>
- generator, even though it actually functions much more like
- <literal>org.hibernate.id.MultipleHiLoPerTableGenerator</literal>, and
- secondly, as a re-implementation of
- <literal>org.hibernate.id.MultipleHiLoPerTableGenerator</literal> that
- utilizes the notion of pluggable optimizers. Essentially this generator
- defines a table capable of holding a number of different increment
- values simultaneously by using multiple distinctly keyed rows. This
- generator has a number of configuration parameters: <itemizedlist
- spacing="compact">
- <listitem>
- <para><literal>table_name</literal> (optional - defaults to
- <literal>hibernate_sequences</literal>): the name of the table to
- be used.</para>
- </listitem>
+ <para>In hbm.xml use the following approach:</para>
- <listitem>
- <para><literal>value_column_name</literal> (optional - defaults to
- <literal>next_val</literal>): the name of the column on the table
- that is used to hold the value.</para>
- </listitem>
+ <programlisting role="XML"><class name="MedicalHistory">
+ <id name="id">
+ <generator class="foreign">
+ <param name="property">patient</param>
+ </generator>
+ </id>
+ <one-to-one name="patient" class="Person" constrained="true"/>
+</class></programlisting>
+ </section>
+ </section>
- <listitem>
- <para><literal>segment_column_name</literal> (optional - defaults
- to <literal>sequence_name</literal>): the name of the column on
- the table that is used to hold the "segment key". This is the
- value which identifies which increment value to use.</para>
- </listitem>
+ <section id="mapping-declaration-id-enhanced">
+ <title>Enhanced identifier generators</title>
- <listitem>
- <para><literal>segment_value</literal> (optional - defaults to
- <literal>default</literal>): The "segment key" value for the
- segment from which we want to pull increment values for this
- generator.</para>
- </listitem>
+ <para>Starting with release 3.2.3, there are 2 new generators which
+ represent a re-thinking of 2 different aspects of identifier
+ generation. The first aspect is database portability; the second is
+ optimization Optimization means that you do not have to query the
+ database for every request for a new identifier value. These two new
+ generators are intended to take the place of some of the named
+ generators described above, starting in 3.3.x. However, they are
+ included in the current releases and can be referenced by FQN.</para>
- <listitem>
- <para><literal>segment_value_length</literal> (optional - defaults
- to <literal>255</literal>): Used for schema generation; the column
- size to create this segment key column.</para>
- </listitem>
+ <para>The first of these new generators is
+ <literal>org.hibernate.id.enhanced.SequenceStyleGenerator</literal>
+ which is intended, firstly, as a replacement for the
+ <literal>sequence</literal> generator and, secondly, as a better
+ portability generator than <literal>native</literal>. This is because
+ <literal>native</literal> generally chooses between
+ <literal>identity</literal> and <literal>sequence</literal> which have
+ largely different semantics that can cause subtle issues in
+ applications eyeing portability.
+ <literal>org.hibernate.id.enhanced.SequenceStyleGenerator</literal>,
+ however, achieves portability in a different manner. It chooses
+ between a table or a sequence in the database to store its
+ incrementing values, depending on the capabilities of the dialect
+ being used. The difference between this and <literal>native</literal>
+ is that table-based and sequence-based storage have the same exact
+ semantic. In fact, sequences are exactly what Hibernate tries to
+ emulate with its table-based generators. This generator has a number
+ of configuration parameters: <itemizedlist spacing="compact">
+ <listitem>
+ <para><literal>sequence_name</literal> (optional, defaults to
+ <literal>hibernate_sequence</literal>): the name of the sequence
+ or table to be used.</para>
+ </listitem>
- <listitem>
- <para><literal>initial_value</literal> (optional - defaults to
- <literal>1</literal>): The initial value to be retrieved from the
- table.</para>
- </listitem>
+ <listitem>
+ <para><literal>initial_value</literal> (optional, defaults to
+ <literal>1</literal>): the initial value to be retrieved from
+ the sequence/table. In sequence creation terms, this is
+ analogous to the clause typically named "STARTS WITH".</para>
+ </listitem>
- <listitem>
- <para><literal>increment_size</literal> (optional - defaults to
- <literal>1</literal>): The value by which subsequent calls to the
- table should differ.</para>
- </listitem>
+ <listitem>
+ <para><literal>increment_size</literal> (optional - defaults to
+ <literal>1</literal>): the value by which subsequent calls to
+ the sequence/table should differ. In sequence creation terms,
+ this is analogous to the clause typically named "INCREMENT
+ BY".</para>
+ </listitem>
- <listitem>
- <para><literal>optimizer</literal> (optional - defaults to
- <literal></literal>): See <xref
- linkend="mapping-declaration-id-enhanced-optimizers" /></para>
- </listitem>
- </itemizedlist></para>
- </section>
+ <listitem>
+ <para><literal>force_table_use</literal> (optional - defaults to
+ <literal>false</literal>): should we force the use of a table as
+ the backing structure even though the dialect might support
+ sequence?</para>
+ </listitem>
- <section id="mapping-declaration-id-enhanced-optimizers">
- <title>Identifier generator optimization</title>
+ <listitem>
+ <para><literal>value_column</literal> (optional - defaults to
+ <literal>next_val</literal>): only relevant for table
+ structures, it is the name of the column on the table which is
+ used to hold the value.</para>
+ </listitem>
- <para>For identifier generators that store values in the database, it is
- inefficient for them to hit the database on each and every call to
- generate a new identifier value. Instead, you can group a bunch of them
- in memory and only hit the database when you have exhausted your
- in-memory value group. This is the role of the pluggable optimizers.
- Currently only the two enhanced generators (<xref
- linkend="mapping-declaration-id-enhanced" /> support this operation.
- <itemizedlist spacing="compact">
- <listitem>
- <para><literal>none</literal> (generally this is the default if no
- optimizer was specified): this will not perform any optimizations
- and hit the database for each and every request.</para>
- </listitem>
+ <listitem>
+ <para><literal>optimizer</literal> (optional - defaults to
+ <literal>none</literal>): See <xref
+ linkend="mapping-declaration-id-enhanced-optimizers" /></para>
+ </listitem>
+ </itemizedlist></para>
- <listitem>
- <para><literal>hilo</literal>: applies a hi/lo algorithm around
- the database retrieved values. The values from the database for
- this optimizer are expected to be sequential. The values retrieved
- from the database structure for this optimizer indicates the
- "group number". The <literal>increment_size</literal> is
- multiplied by that value in memory to define a group "hi
- value".</para>
- </listitem>
+ <para>The second of these new generators is
+ <literal>org.hibernate.id.enhanced.TableGenerator</literal>, which is
+ intended, firstly, as a replacement for the <literal>table</literal>
+ generator, even though it actually functions much more like
+ <literal>org.hibernate.id.MultipleHiLoPerTableGenerator</literal>, and
+ secondly, as a re-implementation of
+ <literal>org.hibernate.id.MultipleHiLoPerTableGenerator</literal> that
+ utilizes the notion of pluggable optimizers. Essentially this
+ generator defines a table capable of holding a number of different
+ increment values simultaneously by using multiple distinctly keyed
+ rows. This generator has a number of configuration parameters:
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para><literal>table_name</literal> (optional - defaults to
+ <literal>hibernate_sequences</literal>): the name of the table
+ to be used.</para>
+ </listitem>
- <listitem>
- <para><literal>pooled</literal>: as with the case of
- <literal>hilo</literal>, this optimizer attempts to minimize the
- number of hits to the database. Here, however, we simply store the
- starting value for the "next group" into the database structure
- rather than a sequential value in combination with an in-memory
- grouping algorithm. Here, <literal>increment_size</literal> refers
- to the values coming from the database.</para>
- </listitem>
- </itemizedlist></para>
- </section>
+ <listitem>
+ <para><literal>value_column_name</literal> (optional - defaults
+ to <literal>next_val</literal>): the name of the column on the
+ table that is used to hold the value.</para>
+ </listitem>
- <section id="mapping-declaration-compositeid" revision="3">
- <title>composite-id</title>
+ <listitem>
+ <para><literal>segment_column_name</literal> (optional -
+ defaults to <literal>sequence_name</literal>): the name of the
+ column on the table that is used to hold the "segment key". This
+ is the value which identifies which increment value to
+ use.</para>
+ </listitem>
- <programlisting role="XML"><composite-id
- name="propertyName"
- class="ClassName"
- mapped="true|false"
- access="field|property|ClassName">
- node="element-name|."
+ <listitem>
+ <para><literal>segment_value</literal> (optional - defaults to
+ <literal>default</literal>): The "segment key" value for the
+ segment from which we want to pull increment values for this
+ generator.</para>
+ </listitem>
- <key-property name="propertyName" type="typename" column="column_name"/>
- <key-many-to-one name="propertyName class="ClassName" column="column_name"/>
- ......
-</composite-id></programlisting>
+ <listitem>
+ <para><literal>segment_value_length</literal> (optional -
+ defaults to <literal>255</literal>): Used for schema generation;
+ the column size to create this segment key column.</para>
+ </listitem>
- <para>A table with a composite key can be mapped with multiple
- properties of the class as identifier properties. The
- <literal><composite-id></literal> element accepts
- <literal><key-property></literal> property mappings and
- <literal><key-many-to-one></literal> mappings as child
- elements.</para>
+ <listitem>
+ <para><literal>initial_value</literal> (optional - defaults to
+ <literal>1</literal>): The initial value to be retrieved from
+ the table.</para>
+ </listitem>
- <programlisting role="XML"><composite-id>
- <key-property name="medicareNumber"/>
- <key-property name="dependent"/>
-</composite-id></programlisting>
+ <listitem>
+ <para><literal>increment_size</literal> (optional - defaults to
+ <literal>1</literal>): The value by which subsequent calls to
+ the table should differ.</para>
+ </listitem>
- <para>The persistent class <emphasis>must</emphasis> override
- <literal>equals()</literal> and <literal>hashCode()</literal> to
- implement composite identifier equality. It must also implement
- <literal>Serializable</literal>.</para>
+ <listitem>
+ <para><literal>optimizer</literal> (optional - defaults to
+ <literal></literal>): See <xref
+ linkend="mapping-declaration-id-enhanced-optimizers" /></para>
+ </listitem>
+ </itemizedlist></para>
- <para>Unfortunately, this approach means that a persistent object is its
- own identifier. There is no convenient "handle" other than the object
- itself. You must instantiate an instance of the persistent class itself
- and populate its identifier properties before you can
- <literal>load()</literal> the persistent state associated with a
- composite key. We call this approach an <emphasis>embedded</emphasis>
- composite identifier, and discourage it for serious applications.</para>
+ <section id="mapping-declaration-id-enhanced-optimizers">
+ <title>Identifier generator optimization</title>
- <para>A second approach is what we call a <emphasis>mapped</emphasis>
- composite identifier, where the identifier properties named inside the
- <literal><composite-id></literal> element are duplicated on both
- the persistent class and a separate identifier class.</para>
+ <para>For identifier generators that store values in the database,
+ it is inefficient for them to hit the database on each and every
+ call to generate a new identifier value. Instead, you can group a
+ bunch of them in memory and only hit the database when you have
+ exhausted your in-memory value group. This is the role of the
+ pluggable optimizers. Currently only the two enhanced generators
+ (<xref linkend="mapping-declaration-id-enhanced" /> support this
+ operation. <itemizedlist spacing="compact">
+ <listitem>
+ <para><literal>none</literal> (generally this is the default
+ if no optimizer was specified): this will not perform any
+ optimizations and hit the database for each and every
+ request.</para>
+ </listitem>
- <programlisting role="XML"><composite-id class="MedicareId" mapped="true">
- <key-property name="medicareNumber"/>
- <key-property name="dependent"/>
-</composite-id></programlisting>
+ <listitem>
+ <para><literal>hilo</literal>: applies a hi/lo algorithm
+ around the database retrieved values. The values from the
+ database for this optimizer are expected to be sequential. The
+ values retrieved from the database structure for this
+ optimizer indicates the "group number". The
+ <literal>increment_size</literal> is multiplied by that value
+ in memory to define a group "hi value".</para>
+ </listitem>
- <para>In this example, both the composite identifier class,
- <literal>MedicareId</literal>, and the entity class itself have
- properties named <literal>medicareNumber</literal> and
- <literal>dependent</literal>. The identifier class must override
- <literal>equals()</literal> and <literal>hashCode()</literal> and
- implement <literal>Serializable</literal>. The main disadvantage of this
- approach is code duplication.</para>
+ <listitem>
+ <para><literal>pooled</literal>: as with the case of
+ <literal>hilo</literal>, this optimizer attempts to minimize
+ the number of hits to the database. Here, however, we simply
+ store the starting value for the "next group" into the
+ database structure rather than a sequential value in
+ combination with an in-memory grouping algorithm. Here,
+ <literal>increment_size</literal> refers to the values coming
+ from the database.</para>
+ </listitem>
+ </itemizedlist></para>
+ </section>
+ </section>
- <para>The following attributes are used to specify a mapped composite
- identifier:</para>
+ <section>
+ <title>Partial identifier generation</title>
- <itemizedlist spacing="compact">
- <listitem>
- <para><literal>mapped</literal> (optional - defaults to
- <literal>false</literal>): indicates that a mapped composite
- identifier is used, and that the contained property mappings refer
- to both the entity class and the composite identifier class.</para>
- </listitem>
+ <para>Hibernate supports the automatic generation of some of the
+ identifier properties. Simply use the
+ <classname>@GeneratedValue</classname> annotation on one or several id
+ properties.</para>
- <listitem>
- <para><literal>class</literal> (optional - but required for a mapped
- composite identifier): the class used as a composite
- identifier.</para>
- </listitem>
- </itemizedlist>
+ <warning>
+ <para>The Hibernate team has always felt such a construct as
+ fundamentally wrong. Try hard to fix your data model before using
+ this feature.</para>
+ </warning>
- <para>We will describe a third, even more convenient approach, where the
- composite identifier is implemented as a component class in <xref
- linkend="components-compositeid" />. The attributes described below
- apply only to this alternative approach:</para>
+ <programlisting language="JAVA" role="JAVA">@Entity
+public class CustomerInventory implements Serializable {
+ @Id
+ @TableGenerator(name = "inventory",
+ table = "U_SEQUENCES",
+ pkColumnName = "S_ID",
+ valueColumnName = "S_NEXTNUM",
+ pkColumnValue = "inventory",
+ allocationSize = 1000)
+ @GeneratedValue(strategy = GenerationType.TABLE, generator = "inventory")
+ Integer id;
- <itemizedlist spacing="compact">
- <listitem>
- <para><literal>name</literal> (optional - required for this
- approach): a property of component type that holds the composite
- identifier. Please see chapter 9 for more information.</para>
- </listitem>
- <listitem>
- <para><literal>access</literal> (optional - defaults to
- <literal>property</literal>): the strategy Hibernate uses for
- accessing the property value.</para>
- </listitem>
+ @Id @ManyToOne(cascade = CascadeType.MERGE)
+ Customer customer;
+}
- <listitem>
- <para><literal>class</literal> (optional - defaults to the property
- type determined by reflection): the component class used as a
- composite identifier. Please see the next section for more
- information.</para>
- </listitem>
- </itemizedlist>
+@Entity
+public class Customer implements Serializable {
+ @Id
+ private int id;
+}</programlisting>
- <para>The third approach, an <emphasis>identifier component</emphasis>,
- is recommended for almost all applications.</para>
+ <para>You can also generate properties inside an
+ <classname>@EmbeddedId</classname> class.</para>
+ </section>
</section>
<section id="mapping-declaration-discriminator" revision="3">
14 years, 7 months
Hibernate SVN: r19329 - in search/trunk: hibernate-search-archetype and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-04-30 11:39:28 -0400 (Fri, 30 Apr 2010)
New Revision: 19329
Modified:
search/trunk/hibernate-search-archetype/pom.xml
search/trunk/pom.xml
Log:
HSEARCH-486
Modified: search/trunk/hibernate-search-archetype/pom.xml
===================================================================
--- search/trunk/hibernate-search-archetype/pom.xml 2010-04-30 08:43:32 UTC (rev 19328)
+++ search/trunk/hibernate-search-archetype/pom.xml 2010-04-30 15:39:28 UTC (rev 19329)
@@ -4,7 +4,7 @@
<!--
The link to the hibernate-search parent POM only exists out of convenience.
- If you want to continue using this quickstart project you should remove this
+ If you want to continue using this quick-start project you should remove this
entry.
-->
<parent>
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2010-04-30 08:43:32 UTC (rev 19328)
+++ search/trunk/pom.xml 2010-04-30 15:39:28 UTC (rev 19329)
@@ -32,8 +32,8 @@
<version>3.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
- <name>Hibernate Search Parent</name>
- <description>Hibernate Search Parent POM</description>
+ <name>Hibernate Search Aggregator</name>
+ <description>Hibernate Search Aggregator POM</description>
<url>http://search.hibernate.org</url>
<modules>
@@ -356,17 +356,6 @@
<type>jdocbook-style</type>
</dependency>
</dependencies>
- <executions>
- <execution>
- <id>make-doc</id>
- <phase>site</phase>
- <goals>
- <goal>translate</goal>
- <goal>resources</goal>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
14 years, 7 months
Hibernate SVN: r19328 - in validator/trunk/hibernate-validator/src/main: java/org/hibernate/validator and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-04-30 04:43:32 -0400 (Fri, 30 Apr 2010)
New Revision: 19328
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/package.html
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/furtherreading.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/package.html
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/resourceloading/package.html
Log:
HV-310 Updated package.html files and docs.
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/furtherreading.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/furtherreading.xml 2010-04-30 08:11:15 UTC (rev 19327)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/furtherreading.xml 2010-04-30 08:43:32 UTC (rev 19328)
@@ -34,9 +34,10 @@
<para>If you have any furhter questions to Hibernate Validator or want to
share some of your use cases have a look at the <ulink
- url="http://www.hibernate.org/469.html">Hibernate Validator Wiki</ulink> and
- the <ulink url="https://forum.hibernate.org/viewforum.php?f=9">Hibernate
- Validator Forum</ulink>.</para>
+ url="http://community.jboss.org/en/hibernate/validator">Hibernate Validator
+ Wiki</ulink> and the <ulink
+ url="https://forum.hibernate.org/viewforum.php?f=9">Hibernate Validator
+ Forum</ulink>.</para>
<para>In case you would like to report a bug use <ulink
url="http://opensource.atlassian.com/projects/hibernate/browse/HV">Hibernate's
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml 2010-04-30 08:11:15 UTC (rev 19327)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml 2010-04-30 08:43:32 UTC (rev 19328)
@@ -26,6 +26,19 @@
annotated domain model) and checked in various different layers of the
application.</para>
+ <section>
+ <title>OSGi</title>
+
+ <para>The Hibernate Validator jar file is conform to the OSGi
+ specification and can be used within any OSGi container. The classes in
+ the following packages are exported by Hibernate Validator and are
+ considered part of the public API -
+ <package>org.hibernate.validator</package>,
+ <package>org.hibernate.validator.constraints</package>,
+ <package>org.hibernate.validator.messageinterpolation</package> and
+ <package>org.hibernate.validator.resourceloading</package>.</para>
+ </section>
+
<section id="validator-checkconstraints-db">
<title>Database schema-level validation</title>
@@ -102,7 +115,7 @@
<title>Manual configuration of
<classname>BeanValidationEvenListener</classname></title>
- <programlisting role="XML" language="XML"><hibernate-configuration>
+ <programlisting language="XML" role="XML"><hibernate-configuration>
<session-factory>
...
<property name="javax.persistence.validation.group.pre-persist">javax.validation.groups.Default</property>
@@ -124,7 +137,7 @@
</section>
<section>
- <title>JPA </title>
+ <title>JPA</title>
<para>If you are using JPA 2 and Hibernate Validator is in the classpath
the JPA2 specification requires that Bean Validation gets enabled. The
@@ -138,7 +151,7 @@
<filename>persistence.xml</filename> also defines a node validation-mode
while can be set to <constant>AUTO</constant>,
<constant>CALLBACK</constant>, <constant>NONE</constant>. The default is
- <constant>AUTO</constant>. </para>
+ <constant>AUTO</constant>.</para>
<para>In a JPA 1 you will have to create and register Hibernate
Validator yourself. In case you are using Hibernate EntityManager you
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/package.html
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/package.html 2010-04-30 08:11:15 UTC (rev 19327)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/package.html 2010-04-30 08:43:32 UTC (rev 19328)
@@ -20,26 +20,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
- <!--
-
- JBoss, Home of Professional Open Source
- Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual contributors
- by the @authors tag. See the copyright.txt in the distribution for a
- full listing of individual contributors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
</head>
<body>
-This package contains implementations of the MessageInterpolator interface.
+Classes in this package are part of the public Hibernate Validator API. The package contains implementations of the
+MessageInterpolator interface in particular ResourceBundleMessageInterpolator which can be used by custom implementations
+of the interface for delegation.
</body>
</html>
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/package.html (from rev 19326, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/package.html)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/package.html (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/package.html 2010-04-30 08:43:32 UTC (rev 19328)
@@ -0,0 +1,28 @@
+<!--
+ ~ $Id:$
+ ~
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual contributors
+ ~ by the @authors tag. See the copyright.txt in the distribution for a
+ ~ full listing of individual contributors.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+</head>
+<body>
+This package contains the classes HibernateValidator and HibernateValidatorConfiguration. These classes are used to
+bootstrap and configure Hibernate Validator and form part of the public Hibernate Validator API.
+</body>
+</html>
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/resourceloading/package.html
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/resourceloading/package.html 2010-04-30 08:11:15 UTC (rev 19327)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/resourceloading/package.html 2010-04-30 08:43:32 UTC (rev 19328)
@@ -21,6 +21,7 @@
-->
</head>
<body>
-This package contains the ResourceBundleLocator interface and different implementations.
+This package contains the ResourceBundleLocator interface and different implementations. It is part of the Hibernate
+Validator public API.
</body>
</html>
14 years, 7 months
Hibernate SVN: r19327 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-04-30 04:11:15 -0400 (Fri, 30 Apr 2010)
New Revision: 19327
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/CreditCardNumber.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Email.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Length.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/NotBlank.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/NotEmpty.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Range.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/ScriptAssert.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/URL.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/package.html
Log:
HV-314 added inner list annotation to be consistent with the bv constraint and follow the spec's recommodation
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/CreditCardNumber.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/CreditCardNumber.java 2010-04-29 22:12:50 UTC (rev 19326)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/CreditCardNumber.java 2010-04-30 08:11:15 UTC (rev 19327)
@@ -37,6 +37,7 @@
* credit card number. This is the Luhn algorithm implementation
* which aims to check for user mistake, not credit card validity!
*
+ * @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
@Documented
@@ -49,4 +50,14 @@
public abstract Class<?>[] groups() default { };
public abstract Class<? extends Payload>[] payload() default { };
+
+ /**
+ * Defines several {@code @CreditCardNumber} annotations on the same element.
+ */
+ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
+ @Retention(RUNTIME)
+ @Documented
+ public @interface List {
+ CreditCardNumber[] value();
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Email.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Email.java 2010-04-29 22:12:50 UTC (rev 19326)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Email.java 2010-04-30 08:11:15 UTC (rev 19327)
@@ -18,19 +18,20 @@
package org.hibernate.validator.constraints;
import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+import org.hibernate.validator.constraints.impl.EmailValidator;
+
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
-import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Target;
-import javax.validation.Constraint;
-import javax.validation.Payload;
-import org.hibernate.validator.constraints.impl.EmailValidator;
-
/**
* The string has to be a well-formed email address.
*
@@ -47,4 +48,14 @@
Class<?>[] groups() default { };
Class<? extends Payload>[] payload() default { };
+
+ /**
+ * Defines several {@code @Email} annotations on the same element.
+ */
+ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
+ @Retention(RUNTIME)
+ @Documented
+ public @interface List {
+ Email[] value();
+ }
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Length.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Length.java 2010-04-29 22:12:50 UTC (rev 19326)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Length.java 2010-04-30 08:11:15 UTC (rev 19327)
@@ -18,20 +18,20 @@
package org.hibernate.validator.constraints;
import java.lang.annotation.Documented;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.CONSTRUCTOR;
-import static java.lang.annotation.ElementType.PARAMETER;
import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import org.hibernate.validator.constraints.impl.LengthValidator;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
/**
* Validate that the string is between min and max included.
*
@@ -52,4 +52,14 @@
Class<?>[] groups() default { };
Class<? extends Payload>[] payload() default { };
+
+ /**
+ * Defines several {@code @Length} annotations on the same element.
+ */
+ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
+ @Retention(RUNTIME)
+ @Documented
+ public @interface List {
+ Length[] value();
+ }
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/NotBlank.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/NotBlank.java 2010-04-29 22:12:50 UTC (rev 19326)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/NotBlank.java 2010-04-30 08:11:15 UTC (rev 19327)
@@ -1,5 +1,5 @@
/*
- * $Id:$
+ * $Id$
*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual contributors
@@ -53,4 +53,14 @@
public abstract Class<?>[] groups() default { };
public abstract Class<? extends Payload>[] payload() default { };
+
+ /**
+ * Defines several {@code @NotBlank} annotations on the same element.
+ */
+ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
+ @Retention(RUNTIME)
+ @Documented
+ public @interface List {
+ NotBlank[] value();
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/NotEmpty.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/NotEmpty.java 2010-04-29 22:12:50 UTC (rev 19326)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/NotEmpty.java 2010-04-30 08:11:15 UTC (rev 19327)
@@ -18,13 +18,7 @@
package org.hibernate.validator.constraints;
import java.lang.annotation.Documented;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.CONSTRUCTOR;
-import static java.lang.annotation.ElementType.PARAMETER;
import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
@@ -32,6 +26,13 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
/**
* Asserts that the annotated string, collection, map or array is not {@code null} or empty.
*
@@ -51,4 +52,14 @@
Class<?>[] groups() default { };
Class<? extends Payload>[] payload() default { };
+
+ /**
+ * Defines several {@code @NotEmpty} annotations on the same element.
+ */
+ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
+ @Retention(RUNTIME)
+ @Documented
+ public @interface List {
+ NotEmpty[] value();
+ }
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Range.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Range.java 2010-04-29 22:12:50 UTC (rev 19326)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/Range.java 2010-04-30 08:11:15 UTC (rev 19327)
@@ -18,13 +18,7 @@
package org.hibernate.validator.constraints;
import java.lang.annotation.Documented;
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.CONSTRUCTOR;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.OverridesAttribute;
@@ -33,6 +27,13 @@
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
/**
* The annotated element has to be in the appropriate range. Apply on numeric values or string
* representation of the numeric value.
@@ -47,15 +48,23 @@
@Max(Long.MAX_VALUE)
@ReportAsSingleViolation
public @interface Range {
- @OverridesAttribute(constraint = Min.class, name = "value")
- long min() default 0;
+ @OverridesAttribute(constraint = Min.class, name = "value") long min() default 0;
- @OverridesAttribute(constraint = Max.class, name = "value")
- long max() default Long.MAX_VALUE;
+ @OverridesAttribute(constraint = Max.class, name = "value") long max() default Long.MAX_VALUE;
String message() default "{org.hibernate.validator.constraints.Range.message}";
Class<?>[] groups() default { };
Class<? extends Payload>[] payload() default { };
+
+ /**
+ * Defines several {@code @Range} annotations on the same element.
+ */
+ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
+ @Retention(RUNTIME)
+ @Documented
+ public @interface List {
+ Range[] value();
+ }
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/ScriptAssert.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/ScriptAssert.java 2010-04-29 22:12:50 UTC (rev 19326)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/ScriptAssert.java 2010-04-30 08:11:15 UTC (rev 19327)
@@ -125,10 +125,7 @@
String alias() default "_this";
/**
- * Defines several @ScriptAssert annotations on the same element.
- *
- * @author Gunnar Morling
- * @see ScriptAssert
+ * Defines several {@code @ScriptAssert} annotations on the same element.
*/
@Target({ TYPE })
@Retention(RUNTIME)
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/URL.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/URL.java 2010-04-29 22:12:50 UTC (rev 19326)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/URL.java 2010-04-30 08:11:15 UTC (rev 19327)
@@ -53,4 +53,14 @@
public abstract Class<?>[] groups() default { };
public abstract Class<? extends Payload>[] payload() default { };
+
+ /**
+ * Defines several {@code @URL} annotations on the same element.
+ */
+ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
+ @Retention(RUNTIME)
+ @Documented
+ public @interface List {
+ URL[] value();
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/package.html
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/package.html 2010-04-29 22:12:50 UTC (rev 19326)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/constraints/package.html 2010-04-30 08:11:15 UTC (rev 19327)
@@ -4,7 +4,7 @@
<!--
JBoss, Home of Professional Open Source
- Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+ Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual contributors
by the @authors tag. See the copyright.txt in the distribution for a
full listing of individual contributors.
@@ -21,6 +21,7 @@
-->
</head>
<body>
-This package contains the Hibernate Validator specific constraints.
+This package contains the Hibernate Validator specific constraints. Classes in this package are part of the public Hibernate
+Validator API.
</body>
</html>
14 years, 7 months
Hibernate SVN: r19326 - in core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable: entitywithmutablecollection/inverse and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-04-29 18:12:50 -0400 (Thu, 29 Apr 2010)
New Revision: 19326
Modified:
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/ContractVariation.hbm.xml
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml
Log:
HHH-5178 : Unit tests in org.hibernate.test.immutable fail on mssql and sybase due to keyword used for table and column name
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/ContractVariation.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/ContractVariation.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/ContractVariation.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -65,7 +65,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="true" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -63,7 +63,7 @@
</set>
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="true" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -70,7 +70,7 @@
</set>
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" table="contract_party" inverse="true" mutable="true" cascade="all">
<key column="contract"/>
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -18,18 +18,18 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -67,7 +67,7 @@
</set>
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="true" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -18,18 +18,18 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -74,7 +74,7 @@
</set>
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" table="contract_party" inverse="true" mutable="true" cascade="all">
<key column="contract"/>
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -63,7 +63,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="false" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -70,7 +70,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" table="contract_party" inverse="false" mutable="true" cascade="all">
<key column="contract"/>
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -18,18 +18,18 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -67,7 +67,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="false" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml 2010-04-29 22:12:50 UTC (rev 19326)
@@ -18,18 +18,18 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -74,7 +74,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" table="contract_party" inverse="false" mutable="true" cascade="all">
<key column="contract"/>
14 years, 7 months
Hibernate SVN: r19325 - in core/trunk/testsuite/src/test/java/org/hibernate/test/immutable: entitywithmutablecollection/inverse and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-04-29 17:23:51 -0400 (Thu, 29 Apr 2010)
New Revision: 19325
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/ContractVariation.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml
Log:
HHH-5178 : Unit tests in org.hibernate.test.immutable fail on mssql and sybase due to keyword used for table and column name
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/ContractVariation.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/ContractVariation.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/ContractVariation.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -65,7 +65,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="true" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -63,7 +63,7 @@
</set>
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="true" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -70,7 +70,7 @@
</set>
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" table="contract_party" inverse="true" mutable="true" cascade="all">
<key column="contract"/>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -18,18 +18,18 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -67,7 +67,7 @@
</set>
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="true" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -18,18 +18,18 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="true" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -74,7 +74,7 @@
</set>
<set name="plans" table="plan_contract" inverse="false" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" table="contract_party" inverse="true" mutable="true" cascade="all">
<key column="contract"/>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -63,7 +63,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="false" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -70,7 +70,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" table="contract_party" inverse="false" mutable="true" cascade="all">
<key column="contract"/>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationUnidir.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -17,17 +17,17 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -18,18 +18,18 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -67,7 +67,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" inverse="false" mutable="true" cascade="all" fetch="join">
<key column="contract"/>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml 2010-04-29 19:02:09 UTC (rev 19324)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml 2010-04-29 21:23:51 UTC (rev 19325)
@@ -18,18 +18,18 @@
<property name="text"/>
</class>
- <class name="Plan" mutable="false">
+ <class name="Plan" table="tbl_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"/>
+ <key column="col_plan"/>
<many-to-many column="contract" class="Contract"/>
</set>
<set name="infos" inverse="false" mutable="true" cascade="all-delete-orphan">
- <key column="plan"/>
+ <key column="col_plan"/>
<one-to-many class="Info"/>
</set>
</class>
@@ -74,7 +74,7 @@
</set>
<set name="plans" table="plan_contract" inverse="true" mutable="true" cascade="none">
<key column="contract"/>
- <many-to-many column="plan" class="Plan"/>
+ <many-to-many column="col_plan" class="Plan"/>
</set>
<set name="parties" table="contract_party" inverse="false" mutable="true" cascade="all">
<key column="contract"/>
14 years, 7 months
Hibernate SVN: r19324 - in validator/trunk/hibernate-validator-annotation-processor/src: main/java/org/hibernate/validator/ap/util and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: gunnar.morling
Date: 2010-04-29 15:02:09 -0400 (Thu, 29 Apr 2010)
New Revision: 19324
Added:
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/AbstractCustomConstraintValidator.java
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraint.java
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraintValidator.java
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/FieldLevelValidationUsingInheritedValidator.java
Modified:
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/ConstraintAnnotationVisitor.java
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util/ConstraintHelper.java
validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/ConstraintValidationProcessorTest.java
Log:
HV-293: If single constraints can't be processed, this is now just logged, then the next constraint will be processed. Will add a "known bug" note to the AP documentation, that some constraints can't properly be processed in Eclipse.
Also added support for validators, which don't implement ConstraintValidator directly but inherit from another class implementing that IF.
Modified: validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/ConstraintAnnotationVisitor.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/ConstraintAnnotationVisitor.java 2010-04-29 18:37:41 UTC (rev 19323)
+++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/ConstraintAnnotationVisitor.java 2010-04-29 19:02:09 UTC (rev 19324)
@@ -210,6 +210,8 @@
Set<ConstraintCheckError> errors = constraintChecks.execute( annotatedElement, oneAnnotationMirror );
messager.reportErrors( errors );
}
+ //HV-293: if single constraints can't be properly checked, report this and
+ //proceed with next constraints
catch ( Exception e ) {
if ( verbose ) {
Modified: validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util/ConstraintHelper.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util/ConstraintHelper.java 2010-04-29 18:37:41 UTC (rev 19323)
+++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util/ConstraintHelper.java 2010-04-29 19:02:09 UTC (rev 19324)
@@ -63,7 +63,7 @@
/**
* Possible results of a constraint check as returned by
- * {@link ConstraintHelper#checkConstraint(DeclaredType, TypeMirror)}. *
+ * {@link ConstraintHelper#checkConstraint(DeclaredType, TypeMirror)}.
*
* @author Gunnar Morling
*/
@@ -503,31 +503,8 @@
}, null
);
- TypeMirror supportedType;
-
- supportedType = getSupportedTypeUsingAnnotationApi( validatorType );
-
- // TODO GM: Due to HV-293 the type supported by a given validator can't
- // always be determined when using
- // the AP within Eclipse. As work around
- // reflection might be used in such cases (meaning that the validator
- // and its supported type have to be on
- // the AP classpath, which normally wasn't required).
-
- if ( supportedType == null ) {
- throw new AssertionError(
- "Couldn't determine the type supported by validator " + validatorType + "."
- );
- }
- return supportedType;
- }
-
- private TypeMirror getSupportedTypeUsingAnnotationApi(
- TypeMirror validatorType) {
-
// contains the bindings of the type parameters from the implemented
- // ConstraintValidator
- // interface, e.g. "ConstraintValidator<CheckCase, String>"
+ // ConstraintValidator interface, e.g. "ConstraintValidator<CheckCase, String>"
TypeMirror constraintValidatorImplementation = getConstraintValidatorSuperType( validatorType );
return constraintValidatorImplementation.accept(
@@ -545,17 +522,31 @@
private TypeMirror getConstraintValidatorSuperType(TypeMirror type) {
- List<? extends TypeMirror> directSupertypes = typeUtils.directSupertypes( type );
+ List<? extends TypeMirror> superTypes = typeUtils.directSupertypes( type );
+ List<TypeMirror> nextSuperTypes = CollectionHelper.newArrayList();
- for ( TypeMirror typeMirror : directSupertypes ) {
- if ( typeUtils.asElement( typeMirror )
- .getSimpleName()
- .contentEquals( ConstraintValidator.class.getSimpleName() ) ) {
- return typeMirror;
+ //follow the type hierarchy upwards, until we have found the ConstraintValidator IF
+ while ( !superTypes.isEmpty() ) {
+
+ for ( TypeMirror oneSuperType : superTypes ) {
+ if ( typeUtils.asElement( oneSuperType ).getSimpleName()
+ .contentEquals( ConstraintValidator.class.getSimpleName() ) ) {
+
+ return oneSuperType;
+ }
+
+ nextSuperTypes.addAll( typeUtils.directSupertypes( oneSuperType ) );
}
+
+ superTypes = nextSuperTypes;
+ nextSuperTypes = CollectionHelper.newArrayList();
}
- return null;
+ //HV-293: Actually this should never happen, as we can have only ConstraintValidator implementations
+ //here. The Eclipse JSR 269 implementation unfortunately doesn't always create the type hierarchy
+ //properly though.
+ //TODO GM: create and report an isolated test case
+ throw new IllegalStateException( "Expected type " + type + " to implement javax.validation.ConstraintValidator, but it doesn't." );
}
/**
Modified: validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/ConstraintValidationProcessorTest.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/ConstraintValidationProcessorTest.java 2010-04-29 18:37:41 UTC (rev 19323)
+++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/ConstraintValidationProcessorTest.java 2010-04-29 19:02:09 UTC (rev 19324)
@@ -53,6 +53,10 @@
import org.hibernate.validator.ap.testmodel.customconstraints.CheckCase;
import org.hibernate.validator.ap.testmodel.customconstraints.CheckCaseValidator;
import org.hibernate.validator.ap.testmodel.customconstraints.FieldLevelValidationUsingCustomConstraints;
+import org.hibernate.validator.ap.testmodel.inheritedvalidator.AbstractCustomConstraintValidator;
+import org.hibernate.validator.ap.testmodel.inheritedvalidator.CustomConstraint;
+import org.hibernate.validator.ap.testmodel.inheritedvalidator.CustomConstraintValidator;
+import org.hibernate.validator.ap.testmodel.inheritedvalidator.FieldLevelValidationUsingInheritedValidator;
import org.hibernate.validator.ap.testmodel.invalidcomposedconstraint.ValidCustomerNumber;
import org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution.NoUniqueValidatorResolution;
import org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution.SerializableCollection;
@@ -157,6 +161,28 @@
}
@Test
+ public void testThatInheritedValidatorClassesAreHandledCorrectly() {
+
+ File sourceFile1 = compilerHelper.getSourceFile( FieldLevelValidationUsingInheritedValidator.class );
+ File sourceFile2 = compilerHelper.getSourceFile( CustomConstraint.class );
+ File sourceFile3 = compilerHelper.getSourceFile( AbstractCustomConstraintValidator.class );
+ File sourceFile4 = compilerHelper.getSourceFile( CustomConstraintValidator.class );
+
+ boolean compilationResult =
+ compilerHelper.compile(
+ new ConstraintValidationProcessor(),
+ diagnostics,
+ sourceFile1,
+ sourceFile2,
+ sourceFile3,
+ sourceFile4
+ );
+
+ assertFalse( compilationResult );
+ assertThatDiagnosticsMatch( diagnostics, new DiagnosticExpection( Kind.ERROR, 30 ) );
+ }
+
+ @Test
public void methodLevelValidationUsingBuiltInConstraints() {
File sourceFile = compilerHelper.getSourceFile( MethodLevelValidationUsingBuiltInConstraints.class );
Added: validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/AbstractCustomConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/AbstractCustomConstraintValidator.java (rev 0)
+++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/AbstractCustomConstraintValidator.java 2010-04-29 19:02:09 UTC (rev 19324)
@@ -0,0 +1,24 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.ap.testmodel.inheritedvalidator;
+
+import javax.validation.ConstraintValidator;
+
+public abstract class AbstractCustomConstraintValidator implements ConstraintValidator<CustomConstraint, String> {
+
+}
Property changes on: validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/AbstractCustomConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraint.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraint.java (rev 0)
+++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraint.java 2010-04-29 19:02:09 UTC (rev 19324)
@@ -0,0 +1,43 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.ap.testmodel.inheritedvalidator;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target({ METHOD, FIELD, ANNOTATION_TYPE })
+@Retention(RUNTIME)
+@Constraint(validatedBy = CustomConstraintValidator.class)
+@Documented
+public @interface CustomConstraint {
+
+ String message() default "";
+
+ Class<?>[] groups() default { };
+
+ Class<? extends Payload>[] payload() default { };
+
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraint.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraintValidator.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraintValidator.java (rev 0)
+++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraintValidator.java 2010-04-29 19:02:09 UTC (rev 19324)
@@ -0,0 +1,30 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.ap.testmodel.inheritedvalidator;
+
+import javax.validation.ConstraintValidatorContext;
+
+public class CustomConstraintValidator extends AbstractCustomConstraintValidator {
+
+ public void initialize(CustomConstraint constraintAnnotation) {
+ }
+
+ public boolean isValid(String object, ConstraintValidatorContext constraintContext) {
+ return true;
+ }
+}
Property changes on: validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/CustomConstraintValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/FieldLevelValidationUsingInheritedValidator.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/FieldLevelValidationUsingInheritedValidator.java (rev 0)
+++ validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/FieldLevelValidationUsingInheritedValidator.java 2010-04-29 19:02:09 UTC (rev 19324)
@@ -0,0 +1,33 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validator.ap.testmodel.inheritedvalidator;
+
+import java.util.Date;
+
+public class FieldLevelValidationUsingInheritedValidator {
+
+ @CustomConstraint
+ public String string;
+
+ /**
+ * Not allowed.
+ */
+ @CustomConstraint
+ public Date date;
+
+}
Property changes on: validator/trunk/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator/FieldLevelValidationUsingInheritedValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
14 years, 7 months
Hibernate SVN: r19323 - validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks.
by hibernate-commits@lists.jboss.org
Author: gunnar.morling
Date: 2010-04-29 14:37:41 -0400 (Thu, 29 Apr 2010)
New Revision: 19323
Modified:
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/ConstraintCheckFactory.java
validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/GetterCheck.java
Log:
HV-316: Fixed typos
Modified: validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/ConstraintCheckFactory.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/ConstraintCheckFactory.java 2010-04-29 15:26:11 UTC (rev 19322)
+++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/ConstraintCheckFactory.java 2010-04-29 18:37:41 UTC (rev 19323)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
@@ -39,7 +39,7 @@
private final Map<AnnotationType, ConstraintChecks> fieldChecks;
/**
- * Holds the checks to be executed for method elements keyed.
+ * Holds the checks to be executed for method elements.
*/
private final Map<AnnotationType, ConstraintChecks> methodChecks;
Modified: validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/GetterCheck.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/GetterCheck.java 2010-04-29 15:26:11 UTC (rev 19322)
+++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/GetterCheck.java 2010-04-29 18:37:41 UTC (rev 19323)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
@@ -31,8 +31,6 @@
* @author Gunnar Morling
*/
public class GetterCheck extends AbstractConstraintCheck {
-
- @Override
public Set<ConstraintCheckError> checkMethod(ExecutableElement element,
AnnotationMirror annotation) {
14 years, 7 months