Hibernate SVN: r10883 - branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-29 22:43:15 -0500 (Wed, 29 Nov 2006)
New Revision: 10883
Added:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_es.properties
Log:
ANN-498 Spanish Validator
Added: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_es.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_es.properties 2006-11-30 03:37:37 UTC (rev 10882)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_es.properties 2006-11-30 03:43:15 UTC (rev 10883)
@@ -0,0 +1,13 @@
+validator.assertFalse=aserci�n fallida
+validator.assertTrue=aserci�n fallida
+validator.future=debe ser una fecha futura
+validator.length=la longitud debe ser entre {min} y {max}
+validator.max=debe ser menor o igual a {value}
+validator.min=debe ser mayor o igual a {value}
+validator.notNull=no puede ser nula
+validator.past=debe ser una fecha pasada
+validator.pattern=debe corresponder a "{regex}"
+validator.range=debe ser entre {min} y {max}
+validator.size=el tama�o debe ser entre {min} y {max}
+validator.email=no es una direcci�n de correo electr�nico bien formada
+validator.notEmpty=no debe ser nulo o vac�o
\ No newline at end of file
18 years
Hibernate SVN: r10882 - in branches/Branch_3_2/HibernateExt/metadata/src: java/org/hibernate/cfg/annotations test/org/hibernate/test/annotations/query
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-29 22:37:37 -0500 (Wed, 29 Nov 2006)
New Revision: 10882
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/CasimirParticle.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/Chaos.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryAndSQLTest.java
Removed:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
Log:
ANN-37 SQL Overriding support
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2006-11-29 15:23:36 UTC (rev 10881)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2006-11-30 03:37:37 UTC (rev 10882)
@@ -22,6 +22,7 @@
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
+import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CollectionId;
@@ -39,6 +40,11 @@
import org.hibernate.annotations.SortType;
import org.hibernate.annotations.Where;
import org.hibernate.annotations.WhereJoinTable;
+import org.hibernate.annotations.SQLInsert;
+import org.hibernate.annotations.SQLUpdate;
+import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.SQLDeleteAll;
+import org.hibernate.annotations.Loader;
import org.hibernate.cfg.AnnotatedClassType;
import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper;
@@ -335,6 +341,37 @@
collection.setCacheRegionName( cacheRegionName );
}
+ //SQL overriding
+ SQLInsert sqlInsert = property.getAnnotation( SQLInsert.class );
+ SQLUpdate sqlUpdate = property.getAnnotation( SQLUpdate.class );
+ SQLDelete sqlDelete = property.getAnnotation( SQLDelete.class );
+ SQLDeleteAll sqlDeleteAll = property.getAnnotation( SQLDeleteAll.class );
+ Loader loader = property.getAnnotation( Loader.class );
+ if ( sqlInsert != null ) {
+ collection.setCustomSQLInsert( sqlInsert.sql().trim(), sqlInsert.callable(),
+ ExecuteUpdateResultCheckStyle.parse( sqlInsert.check().toString().toLowerCase() )
+ );
+
+ }
+ if ( sqlUpdate != null ) {
+ collection.setCustomSQLUpdate( sqlUpdate.sql(), sqlUpdate.callable(),
+ ExecuteUpdateResultCheckStyle.parse( sqlUpdate.check().toString().toLowerCase() )
+ );
+ }
+ if ( sqlDelete != null ) {
+ collection.setCustomSQLDelete( sqlDelete.sql(), sqlDelete.callable(),
+ ExecuteUpdateResultCheckStyle.parse( sqlDelete.check().toString().toLowerCase() )
+ );
+ }
+ if ( sqlDeleteAll != null ) {
+ collection.setCustomSQLDelete( sqlDeleteAll.sql(), sqlDeleteAll.callable(),
+ ExecuteUpdateResultCheckStyle.parse( sqlDeleteAll.check().toString().toLowerCase() )
+ );
+ }
+ if ( loader != null ) {
+ collection.setLoaderName( loader.namedQuery() );
+ }
+
//work on association
boolean isMappedBy = ! BinderHelper.isDefault( mappedBy );
collection.setInverse( isMappedBy );
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2006-11-29 15:23:36 UTC (rev 10881)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2006-11-30 03:37:37 UTC (rev 10882)
@@ -23,20 +23,26 @@
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
+import org.hibernate.annotations.ForceDiscriminator;
+import org.hibernate.annotations.Loader;
import org.hibernate.annotations.OptimisticLockType;
import org.hibernate.annotations.PolymorphismType;
import org.hibernate.annotations.Proxy;
+import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.SQLInsert;
+import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.Tables;
import org.hibernate.annotations.Where;
-import org.hibernate.annotations.ForceDiscriminator;
+import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.cache.CacheFactory;
import org.hibernate.cfg.AnnotationBinder;
+import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.PropertyHolder;
-import org.hibernate.cfg.BinderHelper;
import org.hibernate.engine.Versioning;
+import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
import org.hibernate.mapping.DependantValue;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
@@ -157,6 +163,7 @@
}
persistentClass.setDynamicInsert( dynamicInsert );
persistentClass.setDynamicUpdate( dynamicUpdate );
+
if ( persistentClass instanceof RootClass ) {
RootClass rootClass = (RootClass) persistentClass;
rootClass.setMutable( mutable );
@@ -170,14 +177,14 @@
rootClass.setForceDiscriminator( annotatedClass.isAnnotationPresent( ForceDiscriminator.class ) );
}
else {
- if (explicitHibernateEntityAnnotation) {
- log.warn("@org.hibernate.annotations.Entity used on a non root entity: ignored for "
+ if ( explicitHibernateEntityAnnotation ) {
+ log.warn( "@org.hibernate.annotations.Entity used on a non root entity: ignored for "
+ annotatedClass.getName() );
}
}
persistentClass.setOptimisticLockMode( getVersioning( optimisticLockType ) );
persistentClass.setSelectBeforeUpdate( selectBeforeUpdate );
- if ( ! BinderHelper.isDefault( persister ) ) {
+ if ( !BinderHelper.isDefault( persister ) ) {
try {
persistentClass.setEntityPersisterClass( ReflectHelper.classForName( persister ) );
}
@@ -187,7 +194,38 @@
}
persistentClass.setBatchSize( batchSize );
- if ( ! inheritanceState.hasParents ) {
+ //SQL overriding
+ SQLInsert sqlInsert = annotatedClass.getAnnotation( SQLInsert.class );
+ SQLUpdate sqlUpdate = annotatedClass.getAnnotation( SQLUpdate.class );
+ SQLDelete sqlDelete = annotatedClass.getAnnotation( SQLDelete.class );
+ SQLDeleteAll sqlDeleteAll = annotatedClass.getAnnotation( SQLDeleteAll.class );
+ Loader loader = annotatedClass.getAnnotation( Loader.class );
+ if ( sqlInsert != null ) {
+ persistentClass.setCustomSQLInsert( sqlInsert.sql().trim(), sqlInsert.callable(),
+ ExecuteUpdateResultCheckStyle.parse( sqlInsert.check().toString().toLowerCase() )
+ );
+
+ }
+ if ( sqlUpdate != null ) {
+ persistentClass.setCustomSQLUpdate( sqlUpdate.sql(), sqlUpdate.callable(),
+ ExecuteUpdateResultCheckStyle.parse( sqlUpdate.check().toString().toLowerCase() )
+ );
+ }
+ if ( sqlDelete != null ) {
+ persistentClass.setCustomSQLDelete( sqlDelete.sql(), sqlDelete.callable(),
+ ExecuteUpdateResultCheckStyle.parse( sqlDelete.check().toString().toLowerCase() )
+ );
+ }
+ if ( sqlDeleteAll != null ) {
+ persistentClass.setCustomSQLDelete( sqlDeleteAll.sql(), sqlDeleteAll.callable(),
+ ExecuteUpdateResultCheckStyle.parse( sqlDeleteAll.check().toString().toLowerCase() )
+ );
+ }
+ if ( loader != null ) {
+ persistentClass.setLoaderName( loader.namedQuery() );
+ }
+
+ if ( !inheritanceState.hasParents ) {
Iterator<Map.Entry<String, String>> iter = filters.entrySet().iterator();
while ( iter.hasNext() ) {
Map.Entry<String, String> filter = iter.next();
@@ -213,7 +251,7 @@
try {
mappings.addImport( persistentClass.getEntityName(), name );
String entityName = persistentClass.getEntityName();
- if ( ! entityName.equals( name ) ) {
+ if ( !entityName.equals( name ) ) {
mappings.addImport( entityName, entityName );
}
}
@@ -247,7 +285,7 @@
}
int getVersioning(OptimisticLockType type) {
- switch ( type ) {
+ switch (type) {
case VERSION:
return Versioning.OPTIMISTIC_LOCK_VERSION;
case NONE:
@@ -262,7 +300,7 @@
}
private boolean isExplicitPolymorphism(PolymorphismType type) {
- switch ( type ) {
+ switch (type) {
case IMPLICIT:
return false;
case EXPLICIT:
@@ -383,7 +421,9 @@
);
}
else {
- int nbrOfJoinColumns = pkColumnsAnn != null ? pkColumnsAnn.length : joinColumnsAnn.length;
+ int nbrOfJoinColumns = pkColumnsAnn != null ?
+ pkColumnsAnn.length :
+ joinColumnsAnn.length;
if ( nbrOfJoinColumns == 0 ) {
ejb3JoinColumns = new Ejb3JoinColumn[1];
ejb3JoinColumns[0] = Ejb3JoinColumn.buildJoinColumn(
@@ -397,7 +437,7 @@
else {
ejb3JoinColumns = new Ejb3JoinColumn[nbrOfJoinColumns];
if ( pkColumnsAnn != null ) {
- for ( int colIndex = 0; colIndex < nbrOfJoinColumns ; colIndex++ ) {
+ for ( int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++ ) {
ejb3JoinColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn(
pkColumnsAnn[colIndex],
null,
@@ -408,7 +448,7 @@
}
}
else {
- for ( int colIndex = 0; colIndex < nbrOfJoinColumns ; colIndex++ ) {
+ for ( int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++ ) {
ejb3JoinColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn(
null,
joinColumnsAnn[colIndex],
@@ -493,7 +533,9 @@
else {
throw new AssertionFailure( "Both JoinTable and SecondaryTable are null" );
}
- List uniqueConstraints = new ArrayList( uniqueCosntraintsAnn == null ? 0 : uniqueCosntraintsAnn.length );
+ List uniqueConstraints = new ArrayList( uniqueCosntraintsAnn == null ?
+ 0 :
+ uniqueCosntraintsAnn.length );
if ( uniqueCosntraintsAnn != null && uniqueCosntraintsAnn.length != 0 ) {
for ( UniqueConstraint uc : uniqueCosntraintsAnn ) {
uniqueConstraints.add( uc.columnNames() );
@@ -541,7 +583,9 @@
public void setCache(Cache cacheAnn) {
if ( cacheAnn != null ) {
- cacheRegion = BinderHelper.isDefault( cacheAnn.region() ) ? null : cacheAnn.region();
+ cacheRegion = BinderHelper.isDefault( cacheAnn.region() ) ?
+ null :
+ cacheAnn.region();
cacheConcurrentStrategy = getCacheConcurrencyStrategy( cacheAnn.usage() );
if ( "all".equalsIgnoreCase( cacheAnn.include() ) ) {
cacheLazyProperty = true;
@@ -561,7 +605,7 @@
}
public static String getCacheConcurrencyStrategy(CacheConcurrencyStrategy strategy) {
- switch ( strategy ) {
+ switch (strategy) {
case NONE:
return null;
case READ_ONLY:
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/CasimirParticle.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/CasimirParticle.java 2006-11-29 15:23:36 UTC (rev 10881)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/CasimirParticle.java 2006-11-30 03:37:37 UTC (rev 10882)
@@ -0,0 +1,25 @@
+//$Id: $
+package org.hibernate.test.annotations.query;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name="CASIMIR_PARTICULE")
+public class CasimirParticle {
+ @Id
+ private Long id;
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/Chaos.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/Chaos.java 2006-11-29 15:23:36 UTC (rev 10881)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/Chaos.java 2006-11-30 03:37:37 UTC (rev 10882)
@@ -0,0 +1,83 @@
+//$Id: $
+package org.hibernate.test.annotations.query;
+
+import java.util.Set;
+import java.util.HashSet;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.NamedQuery;
+import javax.persistence.NamedNativeQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.JoinColumn;
+
+import org.hibernate.annotations.SQLInsert;
+import org.hibernate.annotations.SQLUpdate;
+import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.SQLDeleteAll;
+import org.hibernate.annotations.Loader;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name="CHAOS")
+@SQLInsert( sql="INSERT INTO CHAOS(size, name, nickname, id) VALUES(?,upper(?),?,?)")
+@SQLUpdate( sql="UPDATE CHAOS SET size = ?, name = upper(?), nickname = ? WHERE id = ?")
+@SQLDelete( sql="DELETE CHAOS WHERE id = ?")
+@SQLDeleteAll( sql="DELETE CHAOS")
+@Loader(namedQuery = "chaos")
+@NamedNativeQuery(name="chaos", query="select id, size, name, lower( nickname ) as nickname from CHAOS where id= ?", resultClass = Chaos.class)
+public class Chaos {
+ @Id
+ private Long id;
+ private Long size;
+ private String name;
+ private String nickname;
+
+ @OneToMany
+ @JoinColumn(name="chaos_fk")
+ @SQLInsert( sql="UPDATE CASIMIR_PARTICULE SET chaos_fk = ? where id = ?")
+ @SQLDelete( sql="UPDATE CASIMIR_PARTICULE SET chaos_fk = null where id = ?")
+ private Set<CasimirParticle> particles = new HashSet<CasimirParticle>();
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Long getSize() {
+ return size;
+ }
+
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNickname() {
+ return nickname;
+ }
+
+ public void setNickname(String nickname) {
+ this.nickname = nickname;
+ }
+
+ public Set<CasimirParticle> getParticles() {
+ return particles;
+ }
+
+ public void setParticles(Set<CasimirParticle> particles) {
+ this.particles = particles;
+ }
+}
Copied: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryAndSQLTest.java (from rev 10867, branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java)
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java 2006-11-24 00:37:46 UTC (rev 10867)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryAndSQLTest.java 2006-11-30 03:37:37 UTC (rev 10882)
@@ -0,0 +1,380 @@
+//$Id$
+package org.hibernate.test.annotations.query;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.stat.Statistics;
+import org.hibernate.test.annotations.A320;
+import org.hibernate.test.annotations.A320b;
+import org.hibernate.test.annotations.Plane;
+import org.hibernate.test.annotations.TestCase;
+
+/**
+ * Test named queries
+ *
+ * @author Emmanuel Bernard
+ */
+public class QueryAndSQLTest extends TestCase {
+ public QueryAndSQLTest(String x) {
+ super( x );
+ }
+
+ public void testPackageQueries() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Plane p = new Plane();
+ s.persist( p );
+ Query q = s.getNamedQuery( "plane.getAll" );
+ assertEquals( 1, q.list().size() );
+ tx.commit();
+ s.close();
+ }
+
+ public void testClassQueries() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Night n = new Night();
+ Calendar c = new GregorianCalendar();
+ c.set( 2000, 2, 2 );
+ Date now = c.getTime();
+ c.add( Calendar.MONTH, -1 );
+ Date aMonthAgo = c.getTime();
+ c.add( Calendar.MONTH, 2 );
+ Date inAMonth = c.getTime();
+ n.setDate( now );
+ n.setDuration( 14 );
+ s.persist( n );
+ tx.commit();
+ s.close();
+ s = openSession();
+ tx = s.beginTransaction();
+ Query q = s.getNamedQuery( "night.moreRecentThan" );
+ q.setDate( "date", aMonthAgo );
+ assertEquals( 1, q.list().size() );
+ q = s.getNamedQuery( "night.moreRecentThan" );
+ q.setDate( "date", inAMonth );
+ assertEquals( 0, q.list().size() );
+ Statistics stats = getSessions().getStatistics();
+ stats.setStatisticsEnabled( true );
+ stats.clear();
+ q = s.getNamedQuery( "night.duration" );
+ q.setParameter( "duration", 14l );
+ assertEquals( 1, q.list().size() );
+ assertEquals( 1, stats.getQueryCachePutCount() );
+ q = s.getNamedQuery( "night.duration" );
+ q.setParameter( "duration", 14l );
+ s.delete( q.list().get( 0 ) );
+ assertEquals( 1, stats.getQueryCacheHitCount() );
+ tx.commit();
+ s.close();
+ }
+
+ public void testSQLQuery() {
+ Night n = new Night();
+ Calendar c = new GregorianCalendar();
+ c.set( 2000, 2, 2 );
+ Date now = c.getTime();
+ c.add( Calendar.MONTH, -1 );
+ Date aMonthAgo = c.getTime();
+ c.add( Calendar.MONTH, 2 );
+ Date inAMonth = c.getTime();
+ n.setDate( now );
+ n.setDuration( 9999 );
+ Area area = new Area();
+ area.setName( "Monceau" );
+
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( n );
+ s.persist( area );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ Query q = s.getNamedQuery( "night.getAll.bySQL" );
+ q.setParameter( 0, 9990 );
+ List result = q.list();
+ assertEquals( 1, result.size() );
+ Night n2 = (Night) result.get( 0 );
+ assertEquals( n2.getDuration(), n.getDuration() );
+ List areas = s.getNamedQuery( "getAreaByNative" ).list();
+ assertTrue( 1 == areas.size() );
+ assertEquals( area.getName(), ( (Area) areas.get( 0 ) ).getName() );
+ tx.commit();
+ s.close();
+ }
+
+ public void testSQLQueryWithManyToOne() {
+ Night n = new Night();
+ Calendar c = new GregorianCalendar();
+ c.set( 2000, 2, 2 );
+ Date now = c.getTime();
+ c.add( Calendar.MONTH, -1 );
+ Date aMonthAgo = c.getTime();
+ c.add( Calendar.MONTH, 2 );
+ Date inAMonth = c.getTime();
+ n.setDate( now );
+ n.setDuration( 9999 );
+ Area a = new Area();
+ a.setName( "Paris" );
+ n.setArea( a );
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( a );
+ s.persist( n );
+ tx.commit();
+ s.close();
+ s = openSession();
+ tx = s.beginTransaction();
+ Statistics stats = getSessions().getStatistics();
+ stats.setStatisticsEnabled( true );
+ Query q = s.getNamedQuery( "night&areaCached" );
+ List result = q.list();
+ assertEquals( 1, result.size() );
+ assertEquals( 1, stats.getQueryCachePutCount() );
+ q.list();
+ assertEquals( 1, stats.getQueryCacheHitCount() );
+ Night n2 = (Night) ( (Object[]) result.get( 0 ) )[0];
+ assertEquals( n2.getDuration(), n.getDuration() );
+ tx.commit();
+ s.close();
+ }
+
+ public void testImplicitNativeQuery() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ SpaceShip ship = new SpaceShip();
+ ship.setModel( "X-Wing" );
+ ship.setName( "YuBlue" );
+ ship.setSpeed( 2000 );
+ ship.setDimensions( new Dimensions() );
+ s.persist( ship );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ Query q = s.getNamedQuery( "implicitSample" );
+ List result = q.list();
+ assertEquals( 1, result.size() );
+ assertEquals( ship.getModel(), ( (SpaceShip) result.get( 0 ) ).getModel() );
+ s.delete( result.get( 0 ) );
+ tx.commit();
+ s.close();
+ }
+
+ public void testNativeQueryAndCompositePKAndComponents() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ SpaceShip ship = new SpaceShip();
+ ship.setModel( "X-Wing" );
+ ship.setName( "YuBlue" );
+ ship.setSpeed( 2000 );
+ ship.setDimensions( new Dimensions() );
+ ship.getDimensions().setLength( 10 );
+ ship.getDimensions().setWidth( 5 );
+ Captain captain = new Captain();
+ captain.setFirstname( "Luke" );
+ captain.setLastname( "Skywalker" );
+ ship.setCaptain( captain );
+ s.persist( captain );
+ s.persist( ship );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ Query q = s.getNamedQuery( "compositekey" );
+ List result = q.list();
+ assertEquals( 1, result.size() );
+ Object[] row = (Object[]) result.get( 0 );
+ SpaceShip spaceShip = (SpaceShip) row[0];
+ assertEquals( ship.getModel(), spaceShip.getModel() );
+ assertNotNull( spaceShip.getDimensions() );
+ assertEquals( ship.getDimensions().getWidth(), spaceShip.getDimensions().getWidth() );
+ assertEquals( ship.getDimensions().getLength(), spaceShip.getDimensions().getLength() );
+ assertEquals( ship.getCaptain().getFirstname(), ship.getCaptain().getFirstname() );
+ assertEquals( ship.getCaptain().getLastname(), ship.getCaptain().getLastname() );
+ //FIXME vary depending on databases
+ assertTrue( row[1].toString().startsWith( "50" ) );
+ assertTrue( row[2].toString().startsWith( "500" ) );
+ s.delete( spaceShip.getCaptain() );
+ s.delete( spaceShip );
+ tx.commit();
+ s.close();
+ }
+
+ public void testDiscriminator() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Dictionary dic = new Dictionary();
+ dic.setName( "Anglais-Francais" );
+ dic.setEditor( "Harrap's" );
+ SynonymousDictionary syn = new SynonymousDictionary();
+ syn.setName( "Synonymes de tous les temps" );
+ syn.setEditor( "Imagination edition" );
+ s.persist( dic );
+ s.persist( syn );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ List results = s.getNamedQuery( "all.dictionaries" ).list();
+ assertEquals( 2, results.size() );
+ assertTrue(
+ results.get( 0 ) instanceof SynonymousDictionary
+ || results.get( 1 ) instanceof SynonymousDictionary
+ );
+ tx.commit();
+ s.close();
+ }
+
+// public void testScalarQuery() throws Exception {
+// Session s = openSession();
+// Transaction tx;
+// tx = s.beginTransaction();
+// Mark bad = new Mark();
+// bad.value = 5;
+// Mark good = new Mark();
+// good.value = 15;
+// s.persist(bad);
+// s.persist(good);
+// tx.commit();
+// s.clear();
+// tx = s.beginTransaction();
+// List result = s.getNamedQuery("average").list();
+// assertEquals( 1, result.size() );
+// tx.commit();
+// s.close();
+//
+// }
+
+ public void testCache() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Plane plane = new Plane();
+ plane.setNbrOfSeats( 5 );
+ s.persist( plane );
+ tx.commit();
+ s.close();
+ getSessions().getStatistics().clear();
+ getSessions().getStatistics().setStatisticsEnabled( true );
+ s = openSession();
+ tx = s.beginTransaction();
+ Query query = s.getNamedQuery( "plane.byId" ).setParameter( "id", plane.getId() );
+ plane = (Plane) query.uniqueResult();
+ assertEquals( 1, getSessions().getStatistics().getQueryCachePutCount() );
+ plane = (Plane) s.getNamedQuery( "plane.byId" ).setParameter( "id", plane.getId() ).uniqueResult();
+ assertEquals( 1, getSessions().getStatistics().getQueryCacheHitCount() );
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete( s.get( Plane.class, plane.getId() ) );
+ tx.commit();
+ s.close();
+ }
+
+ public void testEntitySQLOverriding() {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Chaos chaos = new Chaos();
+ chaos.setSize( 123l );
+ chaos.setId( 1l );
+
+ String lowerName = "hello";
+ String upperName = lowerName.toUpperCase();
+ assertFalse( lowerName.equals( upperName ) );
+
+ chaos.setName( "hello" );
+ chaos.setNickname( "NickName" );
+ s.persist( chaos );
+ s.flush();
+ s.clear();
+ s.getSessionFactory().evict( Chaos.class );
+
+ Chaos resultChaos = (Chaos) s.load( Chaos.class, chaos.getId() );
+ assertEquals( upperName, resultChaos.getName() );
+ assertEquals( "nickname", resultChaos.getNickname() );
+
+ tx.rollback();
+ s.close();
+ }
+
+ public void testCollectionSQLOverriding() {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Chaos chaos = new Chaos();
+ chaos.setSize( 123l );
+ chaos.setId( 1l );
+
+ chaos.setName( "hello" );
+ s.persist( chaos );
+ CasimirParticle p = new CasimirParticle();
+ p.setId( 1l );
+ s.persist( p );
+ chaos.getParticles().add(p);
+ p = new CasimirParticle();
+ p.setId( 2l );
+ s.persist( p );
+ chaos.getParticles().add(p);
+ s.flush();
+ s.clear();
+ s.getSessionFactory().evict( Chaos.class );
+
+ Chaos resultChaos = (Chaos) s.load( Chaos.class, chaos.getId() );
+ assertEquals( 2, resultChaos.getParticles().size() );
+ resultChaos.getParticles().remove( resultChaos.getParticles().iterator().next() );
+ resultChaos.getParticles().remove( resultChaos.getParticles().iterator().next() );
+ s.flush();
+
+ s.clear();
+ resultChaos = (Chaos) s.load( Chaos.class, chaos.getId() );
+ assertEquals( 0, resultChaos.getParticles().size() );
+
+ tx.rollback();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[]{
+ Plane.class,
+ A320.class,
+ A320b.class,
+ Night.class,
+ Area.class,
+ SpaceShip.class,
+ Dictionary.class,
+ SynonymousDictionary.class,
+ Captain.class,
+ Chaos.class,
+ CasimirParticle.class
+ };
+ }
+
+ protected String[] getAnnotatedPackages() {
+ return new String[]{
+ "org.hibernate.test.annotations.query"
+ };
+ }
+
+ @Override
+ protected String[] getXmlFiles() {
+ return new String[]{
+ "org/hibernate/test/annotations/query/orm.xml"
+ };
+ }
+}
Property changes on: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryAndSQLTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java 2006-11-29 15:23:36 UTC (rev 10881)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/query/QueryTest.java 2006-11-30 03:37:37 UTC (rev 10882)
@@ -1,313 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.query;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.stat.Statistics;
-import org.hibernate.test.annotations.A320;
-import org.hibernate.test.annotations.A320b;
-import org.hibernate.test.annotations.Plane;
-import org.hibernate.test.annotations.TestCase;
-
-/**
- * Test named queries
- *
- * @author Emmanuel Bernard
- */
-public class QueryTest extends TestCase {
- public QueryTest(String x) {
- super( x );
- }
-
- public void testPackageQueries() throws Exception {
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- Plane p = new Plane();
- s.persist( p );
- Query q = s.getNamedQuery( "plane.getAll" );
- assertEquals( 1, q.list().size() );
- tx.commit();
- s.close();
- }
-
- public void testClassQueries() throws Exception {
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- Night n = new Night();
- Calendar c = new GregorianCalendar();
- c.set( 2000, 2, 2 );
- Date now = c.getTime();
- c.add( Calendar.MONTH, -1 );
- Date aMonthAgo = c.getTime();
- c.add( Calendar.MONTH, 2 );
- Date inAMonth = c.getTime();
- n.setDate( now );
- n.setDuration( 14 );
- s.persist( n );
- tx.commit();
- s.close();
- s = openSession();
- tx = s.beginTransaction();
- Query q = s.getNamedQuery( "night.moreRecentThan" );
- q.setDate( "date", aMonthAgo );
- assertEquals( 1, q.list().size() );
- q = s.getNamedQuery( "night.moreRecentThan" );
- q.setDate( "date", inAMonth );
- assertEquals( 0, q.list().size() );
- Statistics stats = getSessions().getStatistics();
- stats.setStatisticsEnabled( true );
- stats.clear();
- q = s.getNamedQuery( "night.duration" );
- q.setParameter( "duration", 14l );
- assertEquals( 1, q.list().size() );
- assertEquals( 1, stats.getQueryCachePutCount() );
- q = s.getNamedQuery( "night.duration" );
- q.setParameter( "duration", 14l );
- s.delete( q.list().get( 0 ) );
- assertEquals( 1, stats.getQueryCacheHitCount() );
- tx.commit();
- s.close();
- }
-
- public void testSQLQuery() {
- Night n = new Night();
- Calendar c = new GregorianCalendar();
- c.set( 2000, 2, 2 );
- Date now = c.getTime();
- c.add( Calendar.MONTH, -1 );
- Date aMonthAgo = c.getTime();
- c.add( Calendar.MONTH, 2 );
- Date inAMonth = c.getTime();
- n.setDate( now );
- n.setDuration( 9999 );
- Area area = new Area();
- area.setName( "Monceau" );
-
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist( n );
- s.persist( area );
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- Query q = s.getNamedQuery( "night.getAll.bySQL" );
- q.setParameter( 0, 9990 );
- List result = q.list();
- assertEquals( 1, result.size() );
- Night n2 = (Night) result.get( 0 );
- assertEquals( n2.getDuration(), n.getDuration() );
- List areas = s.getNamedQuery( "getAreaByNative" ).list();
- assertTrue( 1 == areas.size() );
- assertEquals( area.getName(), ( (Area) areas.get( 0 ) ).getName() );
- tx.commit();
- s.close();
- }
-
- public void testSQLQueryWithManyToOne() {
- Night n = new Night();
- Calendar c = new GregorianCalendar();
- c.set( 2000, 2, 2 );
- Date now = c.getTime();
- c.add( Calendar.MONTH, -1 );
- Date aMonthAgo = c.getTime();
- c.add( Calendar.MONTH, 2 );
- Date inAMonth = c.getTime();
- n.setDate( now );
- n.setDuration( 9999 );
- Area a = new Area();
- a.setName( "Paris" );
- n.setArea( a );
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- s.persist( a );
- s.persist( n );
- tx.commit();
- s.close();
- s = openSession();
- tx = s.beginTransaction();
- Statistics stats = getSessions().getStatistics();
- stats.setStatisticsEnabled( true );
- Query q = s.getNamedQuery( "night&areaCached" );
- List result = q.list();
- assertEquals( 1, result.size() );
- assertEquals( 1, stats.getQueryCachePutCount() );
- q.list();
- assertEquals( 1, stats.getQueryCacheHitCount() );
- Night n2 = (Night) ( (Object[]) result.get( 0 ) )[0];
- assertEquals( n2.getDuration(), n.getDuration() );
- tx.commit();
- s.close();
- }
-
- public void testImplicitNativeQuery() throws Exception {
- Session s;
- Transaction tx;
- s = openSession();
- tx = s.beginTransaction();
- SpaceShip ship = new SpaceShip();
- ship.setModel( "X-Wing" );
- ship.setName( "YuBlue" );
- ship.setSpeed( 2000 );
- ship.setDimensions( new Dimensions() );
- s.persist( ship );
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- Query q = s.getNamedQuery( "implicitSample" );
- List result = q.list();
- assertEquals( 1, result.size() );
- assertEquals( ship.getModel(), ( (SpaceShip) result.get( 0 ) ).getModel() );
- s.delete( result.get( 0 ) );
- tx.commit();
- s.close();
- }
-
- public void testNativeQueryAndCompositePKAndComponents() throws Exception {
- Session s;
- Transaction tx;
- s = openSession();
- tx = s.beginTransaction();
- SpaceShip ship = new SpaceShip();
- ship.setModel( "X-Wing" );
- ship.setName( "YuBlue" );
- ship.setSpeed( 2000 );
- ship.setDimensions( new Dimensions() );
- ship.getDimensions().setLength( 10 );
- ship.getDimensions().setWidth( 5 );
- Captain captain = new Captain();
- captain.setFirstname( "Luke" );
- captain.setLastname( "Skywalker" );
- ship.setCaptain( captain );
- s.persist( captain );
- s.persist( ship );
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- Query q = s.getNamedQuery( "compositekey" );
- List result = q.list();
- assertEquals( 1, result.size() );
- Object[] row = (Object[]) result.get( 0 );
- SpaceShip spaceShip = (SpaceShip) row[0];
- assertEquals( ship.getModel(), spaceShip.getModel() );
- assertNotNull( spaceShip.getDimensions() );
- assertEquals( ship.getDimensions().getWidth(), spaceShip.getDimensions().getWidth() );
- assertEquals( ship.getDimensions().getLength(), spaceShip.getDimensions().getLength() );
- assertEquals( ship.getCaptain().getFirstname(), ship.getCaptain().getFirstname() );
- assertEquals( ship.getCaptain().getLastname(), ship.getCaptain().getLastname() );
- //FIXME vary depending on databases
- assertTrue( row[1].toString().startsWith( "50" ) );
- assertTrue( row[2].toString().startsWith( "500" ) );
- s.delete( spaceShip.getCaptain() );
- s.delete( spaceShip );
- tx.commit();
- s.close();
- }
-
- public void testDiscriminator() throws Exception {
- Session s;
- Transaction tx;
- s = openSession();
- tx = s.beginTransaction();
- Dictionary dic = new Dictionary();
- dic.setName( "Anglais-Francais" );
- dic.setEditor( "Harrap's" );
- SynonymousDictionary syn = new SynonymousDictionary();
- syn.setName( "Synonymes de tous les temps" );
- syn.setEditor( "Imagination edition" );
- s.persist( dic );
- s.persist( syn );
- tx.commit();
- s.clear();
- tx = s.beginTransaction();
- List results = s.getNamedQuery( "all.dictionaries" ).list();
- assertEquals( 2, results.size() );
- assertTrue(
- results.get( 0 ) instanceof SynonymousDictionary
- || results.get( 1 ) instanceof SynonymousDictionary
- );
- tx.commit();
- s.close();
- }
-
-// public void testScalarQuery() throws Exception {
-// Session s = openSession();
-// Transaction tx;
-// tx = s.beginTransaction();
-// Mark bad = new Mark();
-// bad.value = 5;
-// Mark good = new Mark();
-// good.value = 15;
-// s.persist(bad);
-// s.persist(good);
-// tx.commit();
-// s.clear();
-// tx = s.beginTransaction();
-// List result = s.getNamedQuery("average").list();
-// assertEquals( 1, result.size() );
-// tx.commit();
-// s.close();
-//
-// }
-
- public void testCache() throws Exception {
- Session s;
- Transaction tx;
- s = openSession();
- tx = s.beginTransaction();
- Plane plane = new Plane();
- plane.setNbrOfSeats( 5 );
- s.persist( plane );
- tx.commit();
- s.close();
- getSessions().getStatistics().clear();
- getSessions().getStatistics().setStatisticsEnabled( true );
- s = openSession();
- tx = s.beginTransaction();
- Query query = s.getNamedQuery( "plane.byId" ).setParameter( "id", plane.getId() );
- plane = (Plane) query.uniqueResult();
- assertEquals( 1, getSessions().getStatistics().getQueryCachePutCount() );
- plane = (Plane) s.getNamedQuery( "plane.byId" ).setParameter( "id", plane.getId() ).uniqueResult();
- assertEquals( 1, getSessions().getStatistics().getQueryCacheHitCount() );
- tx.commit();
- s.close();
-
- s = openSession();
- tx = s.beginTransaction();
- s.delete( s.get( Plane.class, plane.getId() ) );
- tx.commit();
- s.close();
- }
-
- protected Class[] getMappings() {
- return new Class[]{
- Plane.class,
- A320.class,
- A320b.class,
- Night.class,
- Area.class,
- SpaceShip.class,
- Dictionary.class,
- SynonymousDictionary.class,
- Captain.class
- };
- }
-
- protected String[] getAnnotatedPackages() {
- return new String[]{
- "org.hibernate.test.annotations.query"
- };
- }
-
- @Override
- protected String[] getXmlFiles() {
- return new String[] {
- "org/hibernate/test/annotations/query/orm.xml"
- };
- }
-}
18 years
Hibernate SVN: r10881 - branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-29 10:23:36 -0500 (Wed, 29 Nov 2006)
New Revision: 10881
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Software.java
Log:
ANN-491 more tests
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java 2006-11-29 15:18:34 UTC (rev 10880)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java 2006-11-29 15:23:36 UTC (rev 10881)
@@ -424,8 +424,8 @@
trainee2.setName( "Emmanuel" );
s.persist( trainee );
s.persist( trainee2 );
- training.getTrainees().put("Jim", trainee);
- training.getTrainees().put("Emmanuel", trainee2);
+ training.getTrainees().put( "Jim", trainee );
+ training.getTrainees().put( "Emmanuel", trainee2 );
s.persist( training );
s.flush();
s.clear();
@@ -436,6 +436,44 @@
s.close();
}
+ public void testMapKeyLoad() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Software hibernate = new Software();
+ hibernate.setName( "Hibernate" );
+ Version v1 = new Version();
+ v1.setCodeName( "HumbaHumba" );
+ v1.setNumber( "1.0" );
+ v1.setSoftware( hibernate );
+ hibernate.addVersion( v1 );
+ s.persist( hibernate );
+ s.persist( v1 );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ hibernate = (Software) s.get( Software.class, "Hibernate" );
+ assertEquals(1, hibernate.getVersions().size() );
+ Version v2 = new Version();
+ v2.setCodeName( "HumbaHumba2" );
+ v2.setNumber( "2.0" );
+ v2.setSoftware( hibernate );
+ hibernate.addVersion( v2 );
+ assertEquals( "One loaded persisted version, and one just added", 2, hibernate.getVersions().size() );
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ hibernate = (Software) s.get( Software.class, "Hibernate" );
+ for ( Version v : hibernate.getVersions().values() ) {
+ s.delete( v );
+ }
+ s.delete( hibernate );
+ tx.commit();
+ s.close();
+ }
+
+
public IndexedCollectionTest(String x) {
super( x );
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Software.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Software.java 2006-11-29 15:18:34 UTC (rev 10880)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Software.java 2006-11-29 15:23:36 UTC (rev 10881)
@@ -2,6 +2,7 @@
package org.hibernate.test.annotations.indexcoll;
import java.util.Map;
+import java.util.HashMap;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.MapKey;
@@ -13,7 +14,7 @@
@Entity
public class Software {
private String name;
- private Map<String, Version> versions;
+ private Map<String, Version> versions = new HashMap<String, Version>();
@Id
public String getName() {
@@ -33,4 +34,8 @@
public void setVersions(Map<String, Version> versions) {
this.versions = versions;
}
+
+ public void addVersion(Version version) {
+ this.versions.put(version.getCodeName(), version);
+ }
}
18 years
Hibernate SVN: r10880 - trunk/Hibernate3/src/org/hibernate/mapping
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-29 10:18:34 -0500 (Wed, 29 Nov 2006)
New Revision: 10880
Modified:
trunk/Hibernate3/src/org/hibernate/mapping/DenormalizedTable.java
Log:
ANN-473 unique constraint on TABLE_PER_CLASS
Modified: trunk/Hibernate3/src/org/hibernate/mapping/DenormalizedTable.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/mapping/DenormalizedTable.java 2006-11-29 15:17:28 UTC (rev 10879)
+++ trunk/Hibernate3/src/org/hibernate/mapping/DenormalizedTable.java 2006-11-29 15:18:34 UTC (rev 10880)
@@ -34,6 +34,16 @@
}
}
+ public Column getColumn(Column column) {
+ Column superColumn = super.getColumn( column );
+ if (superColumn != null) {
+ return superColumn;
+ }
+ else {
+ return includedTable.getColumn( column );
+ }
+ }
+
public Iterator getColumnIterator() {
return new JoinedIterator(
includedTable.getColumnIterator(),
18 years
Hibernate SVN: r10879 - in branches/Branch_3_2: Hibernate3/src/org/hibernate/mapping HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-29 10:17:28 -0500 (Wed, 29 Nov 2006)
New Revision: 10879
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/Component.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/Product.java
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/DenormalizedTable.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/TablePerClassTest.java
Log:
ANN-473 unique constraint on TABLE_PER_CLASS
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/DenormalizedTable.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/DenormalizedTable.java 2006-11-29 15:16:32 UTC (rev 10878)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/mapping/DenormalizedTable.java 2006-11-29 15:17:28 UTC (rev 10879)
@@ -34,6 +34,16 @@
}
}
+ public Column getColumn(Column column) {
+ Column superColumn = super.getColumn( column );
+ if (superColumn != null) {
+ return superColumn;
+ }
+ else {
+ return includedTable.getColumn( column );
+ }
+ }
+
public Iterator getColumnIterator() {
return new JoinedIterator(
includedTable.getColumnIterator(),
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/Component.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/Component.java 2006-11-29 15:16:32 UTC (rev 10878)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/Component.java 2006-11-29 15:17:28 UTC (rev 10879)
@@ -0,0 +1,56 @@
+//$Id: $
+package org.hibernate.test.annotations.tableperclass;
+
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.Entity;
+import javax.persistence.InheritanceType;
+
+import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Length;
+import org.hibernate.annotations.Index;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity(name = "xpmComponent")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+public abstract class Component {
+ private String manufacturerPartNumber;
+ private Long manufacturerId;
+ private Long id;
+
+
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+
+ @Id
+ public Long getId() {
+ return id;
+ }
+
+
+ @NotNull
+ @Length(max = 40)
+ @Index(name = "manufacturerPartNumber")
+ public String getManufacturerPartNumber() {
+ return manufacturerPartNumber;
+ }
+
+ @NotNull
+ public Long getManufacturerId() {
+ return manufacturerId;
+ }
+
+ public void setManufacturerId(Long manufacturerId) {
+ this.manufacturerId = manufacturerId;
+ }
+
+
+ public void setManufacturerPartNumber(String manufacturerPartNumber) {
+ this.manufacturerPartNumber = manufacturerPartNumber;
+ }
+}
\ No newline at end of file
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/Product.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/Product.java 2006-11-29 15:16:32 UTC (rev 10878)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/Product.java 2006-11-29 15:17:28 UTC (rev 10879)
@@ -0,0 +1,15 @@
+//$Id: $
+package org.hibernate.test.annotations.tableperclass;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table( name = "xPM_Product", uniqueConstraints = {@UniqueConstraint( columnNames = {
+ "manufacturerPartNumber", "manufacturerId"} )} )
+public class Product extends Component {
+}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/TablePerClassTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/TablePerClassTest.java 2006-11-29 15:16:32 UTC (rev 10878)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tableperclass/TablePerClassTest.java 2006-11-29 15:17:28 UTC (rev 10879)
@@ -2,10 +2,12 @@
package org.hibernate.test.annotations.tableperclass;
import java.util.List;
+import java.sql.SQLException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.JDBCException;
import org.hibernate.test.annotations.TestCase;
/**
@@ -45,6 +47,33 @@
s.close();
}
+ public void testConstraintsOnSuperclassProperties() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Product product1 = new Product();
+ product1.setId( 1l );
+ product1.setManufacturerId( 1l );
+ product1.setManufacturerPartNumber( "AAFR");
+ s.persist( product1 );
+ s.flush();
+ Product product2 = new Product();
+ product2.setId( 2l );
+ product2.setManufacturerId( 1l );
+ product2.setManufacturerPartNumber( "AAFR");
+ s.persist( product2 );
+ try {
+ s.flush();
+ fail("Database Exception not handled");
+ }
+ catch( JDBCException e ) {
+ //success
+ }
+ tx.rollback();
+ s.close();
+ }
+
+
+
public TablePerClassTest(String x) {
super( x ); //To change body of overridden methods use File | Settings | File Templates.
}
@@ -53,7 +82,9 @@
return new Class[]{
Robot.class,
T800.class,
- Machine.class
+ Machine.class,
+ Component.class,
+ Product.class
};
}
}
18 years
Hibernate SVN: r10878 - branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/search/impl
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-29 10:16:32 -0500 (Wed, 29 Nov 2006)
New Revision: 10878
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
Log:
avoid NPE on search session clear
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2006-11-29 14:24:38 UTC (rev 10877)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2006-11-29 15:16:32 UTC (rev 10878)
@@ -213,7 +213,9 @@
}
public void clear() {
- postTransactionWorkQueueSynch.afterCompletion( Status.STATUS_ROLLEDBACK );
+ if (postTransactionWorkQueueSynch != null && !postTransactionWorkQueueSynch.isConsumed() ) {
+ postTransactionWorkQueueSynch.afterCompletion( Status.STATUS_ROLLEDBACK );
+ }
session.clear();
}
18 years
Hibernate SVN: r10877 - in branches/Branch_3_2/HibernateExt/metadata/src: java/org/hibernate/cfg/annotations test/org/hibernate/test/annotations test/org/hibernate/test/annotations/quote
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-29 09:24:38 -0500 (Wed, 29 Nov 2006)
New Revision: 10877
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/QuoteTest.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/Role.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/User.java
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/TableBinder.java
Log:
ANN-476 Remove quotes when passing the values to the naming strategy
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/TableBinder.java 2006-11-29 14:19:45 UTC (rev 10876)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/TableBinder.java 2006-11-29 14:24:38 UTC (rev 10877)
@@ -43,8 +43,8 @@
String constraints;
Table denormalizedSuperTable;
ExtendedMappings mappings;
- private String ownerEntityTable;
- private String associatedEntityTable;
+ private Table ownerEntityTable;
+ private Table associatedEntityTable;
private String propertyName;
private String ownerEntity;
private String associatedEntity;
@@ -89,12 +89,20 @@
public Table bind() {
//logicalName only accurate for assoc table...
String logicalName = mappings.getNamingStrategy()
- .logicalCollectionTableName( name, ownerEntityTable, associatedEntityTable, propertyName );
+ .logicalCollectionTableName(
+ name,
+ ownerEntityTable == null ? null : ownerEntityTable.getName(), //we remove potential quotes
+ associatedEntityTable == null ? null : associatedEntityTable.getName(), //we remove potential quotes
+ propertyName );
String extendedName = name != null ?
mappings.getNamingStrategy().tableName( name ) :
mappings.getNamingStrategy()
.collectionTableName(
- ownerEntity, ownerEntityTable, associatedEntity, associatedEntityTable, propertyName
+ ownerEntity,
+ ownerEntityTable == null ? null : ownerEntityTable.getName(), //we remove potential quotes
+ associatedEntity,
+ associatedEntityTable == null ? null : associatedEntityTable.getName(), //we remove potential quotes
+ propertyName
);
return fillTable(
schema, catalog,
@@ -359,9 +367,9 @@
String propertyName
) {
this.ownerEntity = ownerEntity;
- this.ownerEntityTable = ownerEntityTable;
+ this.ownerEntityTable = ownerEntityTable != null ? new Table(ownerEntityTable) : null;
this.associatedEntity = associatedEntity;
- this.associatedEntityTable = associatedEntityTable;
+ this.associatedEntityTable = associatedEntityTable != null ? new Table(associatedEntityTable) : null;
this.propertyName = propertyName;
this.name = null;
}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/QuoteTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/QuoteTest.java 2006-11-29 14:19:45 UTC (rev 10876)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/QuoteTest.java 2006-11-29 14:24:38 UTC (rev 10877)
@@ -0,0 +1,35 @@
+//$Id: $
+package org.hibernate.test.annotations.quote;
+
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class QuoteTest extends TestCase {
+ public void testQuoteManytoMany() {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ User u = new User();
+ s.persist( u );
+ Role r = new Role();
+ s.persist( r );
+ u.getRoles().add( r );
+ s.flush();
+ s.clear();
+ u = (User) s.get( User.class, u.getId() );
+ assertEquals( 1, u.getRoles().size() );
+ tx.rollback();
+ String role = User.class.getName() + ".roles";
+ assertEquals( "User_Role", getCfg().getCollectionMapping( role ).getCollectionTable().getName() );
+ s.close();
+ }
+ protected Class[] getMappings() {
+ return new Class[] {
+ User.class,
+ Role.class
+ };
+ }
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/Role.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/Role.java 2006-11-29 14:19:45 UTC (rev 10876)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/Role.java 2006-11-29 14:24:38 UTC (rev 10877)
@@ -0,0 +1,22 @@
+//$Id: $
+package org.hibernate.test.annotations.quote;
+
+import java.io.Serializable;
+import javax.persistence.Id;
+import javax.persistence.Entity;
+import javax.persistence.GenerationType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Table;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name = "`Role`")
+public class Role implements Serializable {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+}
\ No newline at end of file
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/User.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/User.java 2006-11-29 14:19:45 UTC (rev 10876)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/quote/User.java 2006-11-29 14:24:38 UTC (rev 10877)
@@ -0,0 +1,44 @@
+//$Id: $
+package org.hibernate.test.annotations.quote;
+
+import java.io.Serializable;
+import java.util.Set;
+import java.util.HashSet;
+import javax.persistence.ManyToMany;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Table;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name = "`User`")
+public class User implements Serializable {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ @ManyToMany
+ private Set<Role> roles = new HashSet<Role>();
+
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Set<Role> getRoles() {
+ return roles;
+ }
+
+ public void setRoles(Set<Role> roles) {
+ this.roles = roles;
+ }
+}
18 years
Hibernate SVN: r10876 - in branches/Branch_3_2/HibernateExt/metadata/src: java/org/hibernate/cfg test/org/hibernate/test/annotations/manytoone
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-29 09:19:45 -0500 (Wed, 29 Nov 2006)
New Revision: 10876
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Frame.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Lens.java
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/BinderHelper.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ManyToOneTest.java
Log:
ANN-477 formula interfere with many to one property-ref
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/BinderHelper.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/BinderHelper.java 2006-11-29 14:11:32 UTC (rev 10875)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/BinderHelper.java 2006-11-29 14:19:45 UTC (rev 10876)
@@ -213,9 +213,9 @@
);
}
//build the list of column names
- for ( int index = 0; index < columns.length ; index++ ) {
+ for ( Ejb3JoinColumn column1 : columns ) {
Column column = new Column(
- mappings.getPhysicalColumnName( columns[index].getReferencedColumn(), referencedTable )
+ mappings.getPhysicalColumnName( column1.getReferencedColumn(), referencedTable )
);
orderedColumns.add( column );
columnsToProperty.put( column, new HashSet<Property>() );
@@ -231,7 +231,8 @@
}
Iterator columnIt = property.getColumnIterator();
while ( columnIt.hasNext() ) {
- Column column = (Column) columnIt.next();
+ Object column = columnIt.next(); //can be a Formula so we don't cast
+ //noinspection SuspiciousMethodCalls
if ( columnsToProperty.containsKey( column ) ) {
columnsToProperty.get( column ).add( property );
}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Frame.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Frame.java 2006-11-29 14:11:32 UTC (rev 10875)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Frame.java 2006-11-29 14:19:45 UTC (rev 10876)
@@ -0,0 +1,52 @@
+//$Id: $
+package org.hibernate.test.annotations.manytoone;
+
+import java.util.Set;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+import org.hibernate.annotations.Formula;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Frame implements Serializable {
+ @Id
+ @GeneratedValue
+ private Long id;
+ @OneToMany( mappedBy = "frame" )
+ private Set<Lens> lenses;
+ @Column( unique = true )
+ private String name;
+ @Formula("lower(name)")
+ private String lowerName;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Set<Lens> getLenses() {
+ return lenses;
+ }
+
+ public void setLenses(Set<Lens> lenses) {
+ this.lenses = lenses;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Lens.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Lens.java 2006-11-29 14:11:32 UTC (rev 10875)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/Lens.java 2006-11-29 14:19:45 UTC (rev 10876)
@@ -0,0 +1,58 @@
+//$Id: $
+package org.hibernate.test.annotations.manytoone;
+
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinColumn;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+import org.hibernate.annotations.Formula;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Lens {
+ @Id
+ @GeneratedValue
+ private Long id;
+ private float focal;
+ @Formula("(1/focal)")
+ private float length;
+ @ManyToOne()
+ @JoinColumn(name="frame_fk", referencedColumnName = "name")
+ private Frame frame;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public float getFocal() {
+ return focal;
+ }
+
+ public void setFocal(float focal) {
+ this.focal = focal;
+ }
+
+ public float getLength() {
+ return length;
+ }
+
+ public void setLength(float length) {
+ this.length = length;
+ }
+
+ public Frame getFrame() {
+ return frame;
+ }
+
+ public void setFrame(Frame frame) {
+ this.frame = frame;
+ }
+}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ManyToOneTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ManyToOneTest.java 2006-11-29 14:11:32 UTC (rev 10875)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytoone/ManyToOneTest.java 2006-11-29 14:19:45 UTC (rev 10876)
@@ -296,6 +296,30 @@
s.close();
}
+ public void testFormulaOnOtherSide() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Frame frame = new Frame();
+ frame.setName( "Prada" );
+ s.persist( frame );
+ Lens l = new Lens();
+ l.setFocal( 2.5f );
+ l.setFrame( frame );
+ s.persist( l );
+ Lens r = new Lens();
+ r.setFocal( 1.2f);
+ r.setFrame( frame );
+ s.persist( r );
+ s.flush();
+ s.clear();
+ frame = (Frame) s.get( Frame.class, frame.getId() );
+ assertEquals( 2, frame.getLenses().size() );
+ assertTrue( frame.getLenses().iterator().next().getLength() <= 1/1.2f );
+ assertTrue( frame.getLenses().iterator().next().getLength() >= 1/2.5f );
+ tx.rollback();
+ s.close();
+ }
+
/**
* @see org.hibernate.test.annotations.TestCase#getMappings()
*/
@@ -317,7 +341,9 @@
User.class,
DistrictUser.class,
Order.class,
- OrderLine.class
+ OrderLine.class,
+ Frame.class,
+ Lens.class
};
}
18 years
Hibernate SVN: r10875 - branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-29 09:11:32 -0500 (Wed, 29 Nov 2006)
New Revision: 10875
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_da.properties
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_de.properties
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_it.properties
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_pt_BR.properties
Log:
ANN-493 i18n
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_da.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_da.properties 2006-11-29 08:03:19 UTC (rev 10874)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_da.properties 2006-11-29 14:11:32 UTC (rev 10875)
@@ -9,4 +9,5 @@
validator.pattern=skal matche "{regex}"
validator.range=skal v�re mellem {min} og {max}
validator.size=antallet skal v�re mellem {min} og {max}
-validator.email=not a well-formed email address
\ No newline at end of file
+validator.email=not a well-formed email address
+validator.notEmpty=m� ikke v�re null eller tom
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_de.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_de.properties 2006-11-29 08:03:19 UTC (rev 10874)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_de.properties 2006-11-29 14:11:32 UTC (rev 10875)
@@ -9,4 +9,5 @@
validator.pattern=muss Ausdruck "{regex}" entsprechen
validator.range=muss zwischen {min} und {max} sein
validator.size=muss zwischen {min} und {max} gross sein
-validator.email=not a well-formed email address
\ No newline at end of file
+validator.email=not a well-formed email address
+validator.notEmpty=kann nicht null oder leer sein
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_it.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_it.properties 2006-11-29 08:03:19 UTC (rev 10874)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_it.properties 2006-11-29 14:11:32 UTC (rev 10875)
@@ -10,3 +10,4 @@
validator.range=deve essere tra {min} e {max}
validator.size=le dimensioni devono essere tra {min} e {max}
validator.email=not a well-formed email address
+validator.notEmpty=non pu� essere nullo o vuoto
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_pt_BR.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_pt_BR.properties 2006-11-29 08:03:19 UTC (rev 10874)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_pt_BR.properties 2006-11-29 14:11:32 UTC (rev 10875)
@@ -9,4 +9,5 @@
validator.pattern=deve ser v�lida de acordo com a express�o "{regex}"
validator.range=deve estar entre {min} e {max}
validator.size=tamanho deve estar entre {min} e {max}
-validator.email=n�o � um email v�lido
\ No newline at end of file
+validator.email=n�o � um email v�lido
+validator.notEmpty=n�o pode ser nulo ou vazio
\ No newline at end of file
18 years
Hibernate SVN: r10874 - trunk/Hibernate3/doc/reference/ja/modules
by hibernate-commits@lists.jboss.org
Author: honma
Date: 2006-11-29 03:03:19 -0500 (Wed, 29 Nov 2006)
New Revision: 10874
Modified:
trunk/Hibernate3/doc/reference/ja/modules/basic_mapping.xml
trunk/Hibernate3/doc/reference/ja/modules/configuration.xml
trunk/Hibernate3/doc/reference/ja/modules/performance.xml
trunk/Hibernate3/doc/reference/ja/modules/query_sql.xml
trunk/Hibernate3/doc/reference/ja/modules/session_api.xml
Log:
remove black circle mark that is translator used.
Modified: trunk/Hibernate3/doc/reference/ja/modules/basic_mapping.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/basic_mapping.xml 2006-11-28 14:09:01 UTC (rev 10873)
+++ trunk/Hibernate3/doc/reference/ja/modules/basic_mapping.xml 2006-11-29 08:03:19 UTC (rev 10874)
@@ -113,78 +113,39 @@
<sect3 id="mapping-declaration-entity-resolution">
<title>
- ��EntityResolver��
-
- ���G���e�B�e�B�E���]���o��
+ �G���e�B�e�B�E���]���o
</title>
<para>
- ��
- As mentioned previously, Hibernate will first attempt to resolve DTDs in its classpath. The
- manner in which it does this is by registering a custom <literal>org.xml.sax.EntityResolver</literal>
- implementation with the SAXReader it uses to read in the xml files. This custom
- <literal>EntityResolver</literal> recognizes two different systemId namespaces.
- ��
-
- ��
�O�q�����悤�ɁAHibernate�͂܂��N���X�p�X���DTD������悤�Ƃ��܂��B
<literal>org.xml.sax.EntityResolver</literal> �̃J�X�^��������
XML�t�@�C����ǂݍ��ނ��߂�SAXReader�ɓo�^���邱�Ƃɂ���āADTD������܂��B
���̃J�X�^���� <literal>EntityResolver</literal> ��2�̈قȂ�V�X�e��ID���O��Ԃ�F�����܂��B
- ��
</para>
<itemizedlist>
<listitem>
<para>
- ��
- a <literal>hibernate namespace</literal> is recognized whenever the
- resolver encounteres a systemId starting with
- <literal>http://hibernate.sourceforge.net/</literal>; the resolver
- attempts to resolve these entities via the classlaoder which loaded
- the Hibernate classes.
- ��
-
- ��
<literal>Hibernate���O���</literal> �́A���]���o��
<literal>http://hibernate.sourceforge.net/</literal> �Ŏn�܂�V�X�e��ID�ɓ��B�����Ƃ��ɁA
�F������܂��B
�����ă��]���o�́AHibernate�̃N���X���[�h�����N���X���[�_��p���āA
�����̃G���e�B�e�B������悤�Ƃ��܂��B
- ��
-
</para>
</listitem>
<listitem>
<para>
- ��
- a <literal>user namespace</literal> is recognized whenever the
- resolver encounteres a systemId using a <literal>classpath://</literal>
- URL protocol; the resolver will attempt to resolve these entities
- via (1) the current thread context classloader and (2) the
- classloader which loaded the Hibernate classes.
- ��
-
-
- ��
<literal>���[�U���O���</literal> �́A���]���o��
URL�v���g�R���� <literal>classpath://</literal> ��g�����V�X�e��ID�ɓ��B�����Ƃ��ɁA
�F������܂��B�����ă��]���o�́A(1)�J�����g�X���b�h�̃R���e�L�X�g�N���X���[�_�[�A
�܂���(2)Hibernate�̃N���X���[�h�����N���X���[�_��g���āA
�����̃G���e�B�e�B������悤�Ƃ��܂��B
- ��
</para>
</listitem>
</itemizedlist>
<para>
- ��
- An example of utilizing user namespacing:
- ��
-
- ��
���L�́A���[�U���O��Ԃ�g������ł��F
- ��
</para>
<programlisting><![CDATA[<?xml version="1.0"?>
@@ -203,15 +164,8 @@
&types;
</hibernate-mapping>]]></programlisting>
<para>
- ��
- Where <literal>types.xml</literal> is a resource in the <literal>your.domain</literal>
- package and contains a custom <xref linkend="mapping-types-custom">typedef</xref>.
- ��
-
- ��
������ <literal>types.xml</literal> �� <literal>your.domain</literal> �p�b�P�[�W��̃��\�[�X�ł���A
�J�X�^�� <xref linkend="mapping-types-custom">typedef</xref> ��܂ނ܂��B
- ��
</para>
</sect3>
Modified: trunk/Hibernate3/doc/reference/ja/modules/configuration.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/configuration.xml 2006-11-28 14:09:01 UTC (rev 10873)
+++ trunk/Hibernate3/doc/reference/ja/modules/configuration.xml 2006-11-29 08:03:19 UTC (rev 10874)
@@ -692,15 +692,7 @@
<literal>auto</literal> (default) | <literal>on_close</literal> |
<literal>after_transaction</literal> | <literal>after_statement</literal>
</para>
-��
<para>
- Note that this setting only affects <literal>Session</literal>s returned from
- <literal>SessionFactory.openSession</literal>. For <literal>Session</literal>s
- obtained through <literal>SessionFactory.getCurrentSession</literal>, the
- <literal>CurrentSessionContext</literal> implementation configured for use
- controls the connection release mode for those <literal>Session</literal>s.
- See <xref linkend="architecture-current-session"/>
-
���ӂ��Ă��������B���̐ݒ�� <literal>SessionFactory.openSession</literal> ����
�擾���� <literal>Session</literal> �����Ɍ��ʂ�����܂��B
<literal>SessionFactory.getCurrentSession</literal> ��ʂ��Ď擾����
@@ -708,7 +700,6 @@
�̎����ɂ���āA�R�l�N�V�����̃����[�X���[�h��ݒ肵�܂��B
<xref linkend="architecture-current-session"/> ��Q�Ƃ��Ă��������B
</para>
-��
</entry>
</row>
<row>
Modified: trunk/Hibernate3/doc/reference/ja/modules/performance.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/performance.xml 2006-11-28 14:09:01 UTC (rev 10873)
+++ trunk/Hibernate3/doc/reference/ja/modules/performance.xml 2006-11-29 08:03:19 UTC (rev 10874)
@@ -635,22 +635,12 @@
</para>
<para revision="1">
-��
- You have the option to tell Hibernate which caching implementation to use by
- specifying the name of a class that implements <literal>org.hibernate.cache.CacheProvider</literal>
- using the property <literal>hibernate.cache.provider_class</literal>. Hibernate
- comes bundled with a number of built-in integrations with open-source cache providers
- (listed below); additionally, you could implement your own and plug it in as
- outlined above. Note that versions prior to 3.2 defaulted to use EhCache as the
- default cache provider; that is no longer the case as of 3.2.
-
Hibernate���g�p����L���b�V�������́A<literal>hibernate.cache.provider_class</literal> �v���p�e�B��
<literal>org.hibernate.cache.CacheProvider</literal> ����������N���X����w�肷�邱�ƂŕύX�ł��܂��B
Hibernate�͑����̃I�[�v���\�[�X�̃L���b�V���v���o�C�_��r���g�C�������Ŏ����Ă��܂��i��Ƀ��X�g������܂��j�B
�����āA�O�ɐ�������悤�ɁA���Ȃ����g���Ǝ��̎������āA�����g�ݍ��ނ��Ƃ�o���܂��B
�o�[�W����3.2���O�ł�EhCache���f�t�H���g�̃L���b�V���v���o�C�_�ł��邱�Ƃɒ��ӂ��Ă��������B
�o�[�W����3.2�ł͂���͓��Ă͂܂�܂���B
-��
</para>
<table frame="topbot" id="cacheproviders" revision="1">
Modified: trunk/Hibernate3/doc/reference/ja/modules/query_sql.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/query_sql.xml 2006-11-28 14:09:01 UTC (rev 10873)
+++ trunk/Hibernate3/doc/reference/ja/modules/query_sql.xml 2006-11-29 08:03:19 UTC (rev 10874)
@@ -112,7 +112,7 @@
</listitem>
</itemizedlist>
- <para>Cat��ID, NAME, BIRTHDATE�̃J������g���ăN���X�Ƀ}�b�s���O�����ꍇ�A
+ <para>Cat��ID, NAME, BIRTHDATE�̃J������g���ăN���X�Ƀ}�b�s���O�����ꍇ�A
��L�̃N�G���͂ǂ����A�v�f��Cat�G���e�B�e�B�ł��郊�X�g��Ԃ��܂��B</para>
<para>�G���e�B�e�B��ʂ̃G���e�B�e�B�� <literal>���Έ�</literal> �Ń}�b�s���O���Ă���ꍇ�́A
Modified: trunk/Hibernate3/doc/reference/ja/modules/session_api.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ja/modules/session_api.xml 2006-11-28 14:09:01 UTC (rev 10873)
+++ trunk/Hibernate3/doc/reference/ja/modules/session_api.xml 2006-11-29 08:03:19 UTC (rev 10874)
@@ -460,20 +460,12 @@
<para> ���ۂ̃v���O�����R�[�h�́A�g����N�G������Ɉˑ����Ă��Ȃ����Ƃɒ��ӂ��܂��傤�B
���^�f�[�^�ɂ́A�l�C�e�B�uSQL�N�G�����`���邱�Ƃ�ł��܂��B �܂��A�����̃N�G����}�b�s���O�t�@�C���Ɉڂ����ƂŁA
Hibernate�Ɉڍs���邱�Ƃ�ł��܂��B </para>
- ��
<para>
- Also note that a query declaration inside a <literal><hibernate-mapping></literal>
- element requires a global unique name for the query, while a query declaration inside a
- <literal><class></literal> element is made unique automatically by prepending the
- fully qualified name of the class, for example
- <literal>eg.Cat.ByNameAndMaximumWeight</literal>.
-
<literal><hibernate-mapping></literal> �̒��̃N�G����`�́A�N�G���ɑ���
���j�[�N�Ȗ��O���K�v�Ȃ��Ƃɂ���ӂ��Ă��������B����ɑ��āA <literal><class></literal> �̒���
�N�G����`�́A�N���X�̊��S���薼���O�ɕt������̂ŁA�����I�Ƀ��j�[�N�Ȗ��O�ɂȂ�܂��B
��F <literal>eg.Cat.ByNameAndMaximumWeight</literal>
</para>
- ��
</sect3>
</sect2>
18 years