Hibernate SVN: r18423 - core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-06 12:52:44 -0500 (Wed, 06 Jan 2010)
New Revision: 18423
Modified:
core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java
Log:
minor change, correct javadoc spell
Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java 2010-01-06 17:49:11 UTC (rev 18422)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java 2010-01-06 17:52:44 UTC (rev 18423)
@@ -84,7 +84,7 @@
* <tr>
* <td><tt>hibernate.connection.provider_class</tt></td>
* <td>classname of <tt>org.hibernate.connection.ConnectionProvider</tt>
- * subclass (if not specified hueristics are used)</td>
+ * subclass (if not specified heuristics are used)</td>
* </tr>
* <tr><td><tt>hibernate.connection.username</tt></td><td>database username</td></tr>
* <tr><td><tt>hibernate.connection.password</tt></td><td>database password</td></tr>
@@ -109,7 +109,7 @@
* </tr>
* <tr>
* <td><tt>hibernate.connection.datasource</tt></td>
- * <td>databasource JNDI name (when using <tt>javax.sql.Datasource</tt>)</td>
+ * <td>datasource JNDI name (when using <tt>javax.sql.Datasource</tt>)</td>
* </tr>
* <tr>
* <td><tt>hibernate.jndi.url</tt></td><td>JNDI <tt>InitialContext</tt> URL</td>
@@ -290,7 +290,7 @@
public static final String USE_STREAMS_FOR_BINARY = "hibernate.jdbc.use_streams_for_binary";
/**
* Use JDBC scrollable <tt>ResultSet</tt>s. This property is only necessary when there is
- * no <tt>ConnectionProvider</tt>, ie. the user is supplying JDBC connections.
+ * no <tt>ConnectionProvider</tt>, i.e. the user is supplying JDBC connections.
*/
public static final String USE_SCROLLABLE_RESULTSET = "hibernate.jdbc.use_scrollable_resultset";
/**
@@ -430,7 +430,7 @@
*/
public static final String USE_SECOND_LEVEL_CACHE = "hibernate.cache.use_second_level_cache";
/**
- * Optimize the cache for mimimal puts instead of minimal gets
+ * Optimize the cache for minimal puts instead of minimal gets
*/
public static final String USE_MINIMAL_PUTS = "hibernate.cache.use_minimal_puts";
/**
@@ -507,7 +507,7 @@
public static final String DEFAULT_ENTITY_MODE = "hibernate.default_entity_mode";
/**
- * The jacc context id of the deployment
+ * The JACC context id of the deployment
*/
public static final String JACC_CONTEXTID = "hibernate.jacc_context_id";
14 years, 11 months
Hibernate SVN: r18422 - core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-06 12:49:11 -0500 (Wed, 06 Jan 2010)
New Revision: 18422
Modified:
core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java
Log:
minor change, correct javadoc spell
Modified: core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java 2010-01-06 17:28:23 UTC (rev 18421)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/cfg/Environment.java 2010-01-06 17:49:11 UTC (rev 18422)
@@ -497,7 +497,7 @@
public static final String ORDER_UPDATES = "hibernate.order_updates";
/**
- * Enable ordering of insert statements for the purpose of more effecient JDBC batching.
+ * Enable ordering of insert statements for the purpose of more efficient JDBC batching.
*/
public static final String ORDER_INSERTS = "hibernate.order_inserts";
14 years, 11 months
Hibernate SVN: r18421 - in core/trunk/annotations/src: test/java/org/hibernate/test/annotations/indexcoll and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-01-06 12:28:23 -0500 (Wed, 06 Jan 2010)
New Revision: 18421
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/indexcoll/AddressBook.java
Log:
HHH-4283 fix the incorrect test case and add a proper exception when the user error occurs
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-06 17:01:04 UTC (rev 18420)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-06 17:28:23 UTC (rev 18421)
@@ -35,6 +35,7 @@
import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.MapKey;
@@ -464,6 +465,15 @@
//work on association
boolean isMappedBy = !BinderHelper.isDefault( mappedBy );
+
+ if (isMappedBy
+ && (property.isAnnotationPresent( JoinColumn.class )
+ || property.isAnnotationPresent( JoinTable.class ) ) ) {
+ String message = "Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn: ";
+ message += StringHelper.qualify( propertyHolder.getPath(), propertyName );
+ throw new AnnotationException( message );
+ }
+
collection.setInverse( isMappedBy );
//many to many may need some second pass informations
@@ -487,7 +497,7 @@
|| property.isAnnotationPresent( CollectionOfElements.class ) //legacy hibernate
|| property.isAnnotationPresent( ElementCollection.class ) //JPA 2
) {
- // do it right away, otherwise @ManyToon on composite element call addSecondPass
+ // do it right away, otherwise @ManyToOne on composite element call addSecondPass
// and raise a ConcurrentModificationException
//sp.doSecondPass( CollectionHelper.EMPTY_MAP );
mappings.addSecondPass( sp, !isMappedBy );
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/indexcoll/AddressBook.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/indexcoll/AddressBook.java 2010-01-06 17:01:04 UTC (rev 18420)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/indexcoll/AddressBook.java 2010-01-06 17:28:23 UTC (rev 18421)
@@ -42,7 +42,6 @@
@MapKey
@OneToMany(mappedBy = "book", cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE})
- @JoinTable(name="AddRegEntry")
public Map<AddressEntryPk, AddressEntry> getEntries() {
return entries;
}
@@ -63,7 +62,6 @@
@MapKey(name = "directory")
@OneToMany(mappedBy = "book")
- @JoinTable(name="Dir_Entry")
public Map<AlphabeticalDirectory, AddressEntry> getDirectoryEntries() {
return directoryEntries;
}
14 years, 11 months
Hibernate SVN: r18420 - core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops.
by hibernate-commits@lists.jboss.org
Author: smarlow(a)redhat.com
Date: 2010-01-06 12:01:04 -0500 (Wed, 06 Jan 2010)
New Revision: 18420
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/OrderByTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/Products.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/Widgets.java
Log:
HHH-4688 Make sure @OrderBy works for @ElementCollection. added test case
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/OrderByTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/OrderByTest.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/OrderByTest.java 2010-01-06 17:01:04 UTC (rev 18420)
@@ -0,0 +1,61 @@
+package org.hibernate.ejb.test.ops;
+
+import org.hibernate.ejb.test.TestCase;
+
+import javax.persistence.EntityManager;
+import java.util.HashSet;
+import java.util.Iterator;
+
+public class OrderByTest extends TestCase {
+
+ public Class[] getAnnotatedClasses() {
+ return new Class[]{
+ Products.class,
+ Widgets.class
+ };
+ }
+
+ /**
+ * Test @OrderBy on the Widgets.name field.
+ *
+ */
+ public void testOrderByName() throws Exception {
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+
+ Products p = new Products();
+ HashSet<Widgets> set = new HashSet<Widgets>();
+
+ Widgets widget = new Widgets();
+ widget.setName("hammer");
+ set.add(widget);
+ em.persist(widget);
+
+ widget = new Widgets();
+ widget.setName("axel");
+ set.add(widget);
+ em.persist(widget);
+
+ widget = new Widgets();
+ widget.setName("screwdriver");
+ set.add(widget);
+ em.persist(widget);
+
+ p.setWidgets(set);
+ em.persist(p);
+ em.getTransaction().commit();
+
+ em.getTransaction().begin();
+ em.clear();
+ p = em.find(Products.class,p.getId());
+ assertTrue("has three Widgets", p.getWidgets().size() == 3);
+ Iterator iter = p.getWidgets().iterator();
+ assertEquals( "axel", ((Widgets)iter.next()).getName() );
+ assertEquals( "hammer", ((Widgets)iter.next()).getName() );
+ assertEquals( "screwdriver", ((Widgets)iter.next()).getName() );
+ em.getTransaction().commit();
+ em.close();
+ }
+
+
+}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/Products.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/Products.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/Products.java 2010-01-06 17:01:04 UTC (rev 18420)
@@ -0,0 +1,39 @@
+package org.hibernate.ejb.test.ops;
+
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OrderBy;
+
+import java.util.Set;
+
+@SuppressWarnings({"unchecked", "serial"})
+
+@Entity
+public class Products {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ @ElementCollection
+ @OrderBy("name ASC")
+ private Set<Widgets> widgets;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Set<Widgets> getWidgets() {
+ return widgets;
+ }
+
+ public void setWidgets(Set<Widgets> widgets) {
+ this.widgets = widgets;
+ }
+
+}
\ No newline at end of file
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/Widgets.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/Widgets.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ops/Widgets.java 2010-01-06 17:01:04 UTC (rev 18420)
@@ -0,0 +1,34 @@
+package org.hibernate.ejb.test.ops;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Widgets {
+ private String name;
+ private int id;
+
+ public Widgets() {
+
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+}
14 years, 11 months
Hibernate SVN: r18419 - core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations.
by hibernate-commits@lists.jboss.org
Author: smarlow(a)redhat.com
Date: 2010-01-06 11:59:34 -0500 (Wed, 06 Jan 2010)
New Revision: 18419
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
Log:
HHH-4688 Make sure @OrderBy works for @ElementCollection. Handle default case
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-06 14:37:38 UTC (rev 18418)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-06 16:59:34 UTC (rev 18419)
@@ -1243,7 +1243,8 @@
element.setFetchMode( FetchMode.JOIN );
element.setLazy( false );
element.setIgnoreNotFound( ignoreNotFound );
- if ( StringHelper.isNotEmpty( hqlOrderBy ) ) {
+ // as per 11.1.38 of JPA-2 spec, default to primary key if no column is specified by @OrderBy.
+ if ( hqlOrderBy != null ) {
collValue.setManyToManyOrdering(
buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
);
14 years, 11 months
Hibernate SVN: r18418 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-01-06 09:37:38 -0500 (Wed, 06 Jan 2010)
New Revision: 18418
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Position.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Square.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java
Log:
HHH-4527 - added another test to verify that @Access specified on embeddable directly gets picked up.
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java 2010-01-05 21:51:35 UTC (rev 18417)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java 2010-01-06 14:37:38 UTC (rev 18418)
@@ -192,6 +192,29 @@
s.close();
}
+ public void testEmbeddableExplicitAccessStrategy() throws Exception {
+ Square square = new Square();
+ Position pos = new Position( 10, 15 );
+ square.setPosition( pos );
+ Session s = openSession();
+ s.persist( square );
+ Transaction tx = s.beginTransaction();
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ square = ( Square ) s.get( Square.class, square.getId() );
+ assertEquals( 10, square.getPosition().x );
+ try {
+ square.getPosition().getX();
+ fail();
+ } catch (RuntimeException e) {
+ // success
+ }
+ s.delete( square );
+ tx.commit();
+ s.close();
+ }
+
protected Class[] getMappings() {
return new Class[] {
Bed.class,
@@ -204,7 +227,9 @@
User.class,
Shape.class,
Circle.class,
- Color.class
+ Color.class,
+ Square.class,
+ Position.class
};
}
}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Position.java (from rev 18417, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Color.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Position.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Position.java 2010-01-06 14:37:38 UTC (rev 18418)
@@ -0,0 +1,64 @@
+//$Id: Being.java 18260 2009-12-17 21:14:07Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.Embeddable;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Embeddable
+(a)Access(AccessType.FIELD)
+public class Position {
+ public int x;
+ public int y;
+
+ public Position() {
+ }
+
+ public Position(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public int getX() {
+ throw new RuntimeException( );
+ }
+
+ public void setX(int x) {
+ this.x = x;
+ }
+
+ public int getY() {
+ throw new RuntimeException( );
+ }
+
+ public void setY(int y) {
+ this.y = y;
+ }
+}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Square.java (from rev 18417, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Circle.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Square.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Square.java 2010-01-06 14:37:38 UTC (rev 18418)
@@ -0,0 +1,61 @@
+//$Id: Being.java 18260 2009-12-17 21:14:07Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Square {
+
+ private long id;
+
+ @Embedded
+ private Position position;
+
+ @Id
+ @GeneratedValue
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+
+ public void setPosition(Position position) {
+ this.position = position;
+ }
+}
\ No newline at end of file
14 years, 11 months
Hibernate SVN: r18417 - in core/trunk/annotations/src: main/java/org/hibernate/cfg/annotations and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-01-05 16:51:35 -0500 (Tue, 05 Jan 2010)
New Revision: 18417
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Animal.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Circle.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Color.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course1.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course2.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course3.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course4.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course5.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course6.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course7.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Horse.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Shape.java
Removed:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess2.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess3.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess4.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseFieldAccess.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CoursePropertyAccess.java
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/InheritanceState.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyContainer.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Furniture.java
Log:
HHH-4527 - added handling of proper default access propagation for class hierarchies and embedded classes (components)
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -35,7 +35,6 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import javax.persistence.Access;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.DiscriminatorType;
@@ -191,8 +190,6 @@
* bindSomething usually create the mapping container and is accessed by one of the 2 first level method
* makeSomething usually create the mapping container and is accessed by bindSomething[else]
* fillSomething take the container into parameter and fill it.
- *
- *
*/
private AnnotationBinder() {
}
@@ -618,7 +615,7 @@
);
}
- //try to find class level generators
+ // try to find class level generators
HashMap<String, IdGenerator> classGenerators = buildLocalGenerators( clazzToProcess, mappings );
// check properties
@@ -626,9 +623,6 @@
getElementsToProcess(
persistentClass, clazzToProcess, inheritanceStatePerClass, entityBinder, mappings
);
- if ( elements == null ) {
- throw new AnnotationException( "No identifier specified for entity: " + propertyHolder.getEntityName() );
- }
final boolean subclassAndSingleTableStrategy = inheritanceState.getType() == InheritanceType.SINGLE_TABLE
&& inheritanceState.hasParents();
//process idclass if any
@@ -644,9 +638,7 @@
idClass = current.getAnnotation( IdClass.class );
break;
}
- state = InheritanceState.getSuperclassInheritanceState(
- current, inheritanceStatePerClass, mappings.getReflectionManager()
- );
+ state = InheritanceState.getSuperclassInheritanceState( current, inheritanceStatePerClass );
}
while ( state != null );
}
@@ -657,10 +649,10 @@
String generatorType = "assigned";
String generator = BinderHelper.ANNOTATION_STRING_DEFAULT;
PropertyData inferredData = new PropertyPreloadedData(
- entityBinder.getPropertyAccessor(), "id", compositeClass
+ entityBinder.getPropertyAccessType(), "id", compositeClass
);
PropertyData baseInferredData = new PropertyPreloadedData(
- entityBinder.getPropertyAccessor(), "id", current
+ entityBinder.getPropertyAccessType(), "id", current
);
HashMap<String, IdGenerator> localGenerators = new HashMap<String, IdGenerator>();
boolean ignoreIdAnnotations = entityBinder.isIgnoreIdAnnotations();
@@ -834,11 +826,7 @@
}
private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings, InheritanceState inheritanceState) {
- final ReflectionManager reflectionManager = mappings.getReflectionManager();
- InheritanceState superEntityState =
- InheritanceState.getInheritanceStateOfSuperEntity(
- clazzToProcess, inheritanceStatePerClass, reflectionManager
- );
+ InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( clazzToProcess, inheritanceStatePerClass );
PersistentClass superEntity = superEntityState != null ?
mappings.getClass(
superEntityState.getClazz().getName()
@@ -880,8 +868,7 @@
}
/*
- * Get the annotated elements
- * Guess the annotated element from @Id or @EmbeddedId presence
+ * Get the annotated elements, guessing the access type from @Id or @EmbeddedId presence.
* Change EntityBinder by side effect
*/
private static List<PropertyData> getElementsToProcess(
@@ -892,104 +879,50 @@
InheritanceState inheritanceState = inheritanceStatePerClass.get( clazzToProcess );
assert !inheritanceState.isEmbeddableSuperclass();
- AccessType accessType = determineExplicitAccessType(
- clazzToProcess, inheritanceStatePerClass, mappings, inheritanceState
- );
List<XClass> classesToProcess = getMappedSuperclassesTillNextEntityOrdered(
persistentClass, clazzToProcess, inheritanceStatePerClass, mappings
);
+
+ AccessType accessType = determineDefaultAccessType( clazzToProcess, inheritanceStatePerClass );
+
List<PropertyData> elements = new ArrayList<PropertyData>();
int deep = classesToProcess.size();
boolean hasIdentifier = false;
- /*
- * delay the exception in case field access is used
- */
- AnnotationException exceptionWhileWalkingElements = null;
- try {
- for (int index = 0; index < deep; index++) {
- PropertyContainer properyContainer = new PropertyContainer( classesToProcess.get( index ) );
- boolean currentHasIdentifier = addElementsOfClass( elements, accessType , properyContainer, mappings );
- hasIdentifier = hasIdentifier || currentHasIdentifier;
- }
+ for ( int index = 0; index < deep; index++ ) {
+ PropertyContainer properyContainer = new PropertyContainer( classesToProcess.get( index ) );
+ boolean currentHasIdentifier = addElementsOfClass( elements, accessType, properyContainer, mappings );
+ hasIdentifier = hasIdentifier || currentHasIdentifier;
}
- catch ( AnnotationException e ) {
- exceptionWhileWalkingElements = e;
- }
+ entityBinder.setPropertyAccessType( accessType );
+
if ( !hasIdentifier && !inheritanceState.hasParents() ) {
- if ( AccessType.PROPERTY.equals( accessType ) ) {
- //the original exception is legitimate
- if ( exceptionWhileWalkingElements != null) throw exceptionWhileWalkingElements;
- return null; //explicit but no @Id: the upper layer will raise an exception
- }
- accessType = AccessType.FIELD;
- elements.clear();
- for (int index = 0; index < deep; index++) {
- PropertyContainer properyContainer = new PropertyContainer( classesToProcess.get( index ) );
- boolean currentHasIdentifier = addElementsOfClass(elements, accessType, properyContainer, mappings );
- hasIdentifier = hasIdentifier || currentHasIdentifier;
- }
+ throw new AnnotationException( "No identifier specified for entity: " + clazzToProcess.getName() );
}
- //the field show no id, fallback to he original exception
- if (!hasIdentifier && exceptionWhileWalkingElements != null) throw exceptionWhileWalkingElements;
-
- entityBinder.setPropertyAccessor( accessType );
- inheritanceState.setAccessType( accessType );
- return hasIdentifier || inheritanceState.hasParents() ?
- elements :
- null;
+ return elements;
}
- /*
- * Check whether either the class itself or any of its super classes explicitly defines a value access strategy.
- *
- * @return {@code AccessType.FIELD} or {@code AccessType.PROPERTY} in case there is an explicit value,
- * {@code AccessType.DEFAULT} otherwise.
- */
- private static AccessType determineExplicitAccessType(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings, InheritanceState inheritanceState) {
- AccessType explicitAccessType = AccessType.DEFAULT;
-
- // check whether any of the super classes or the class itself
- if ( inheritanceState.hasParents() ) {
- InheritanceState superEntityState =
- InheritanceState.getInheritanceStateOfSuperEntity(
- clazzToProcess, inheritanceStatePerClass, mappings.getReflectionManager()
- );
- if ( superEntityState != null ) {
- explicitAccessType = superEntityState.getAccessType();
+ private static AccessType determineDefaultAccessType(XClass annotatedClass, Map<XClass, InheritanceState> inheritanceStatePerClass) {
+ XClass xclass = annotatedClass;
+ while ( xclass != null && !Object.class.getName().equals( xclass.getName() ) ) {
+ if ( xclass.isAnnotationPresent( Entity.class ) || xclass.isAnnotationPresent( MappedSuperclass.class ) ) {
+ for ( XProperty prop : xclass.getDeclaredProperties( AccessType.PROPERTY.getType() ) ) {
+ if ( prop.isAnnotationPresent( Id.class ) || prop.isAnnotationPresent( EmbeddedId.class ) ) {
+ return AccessType.PROPERTY;
+ }
+ }
+ for ( XProperty prop : xclass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
+ if ( prop.isAnnotationPresent( Id.class ) || prop.isAnnotationPresent( EmbeddedId.class ) ) {
+ return AccessType.FIELD;
+ }
+ }
}
+ xclass = xclass.getSuperclass();
}
- else {
- AccessType hibernateExplicitAccessType = AccessType.DEFAULT;
- AccessType jpaExplicitAccessType = AccessType.DEFAULT;
-
- //the are the root entity but we might have mapped superclasses that contain the id class
- org.hibernate.annotations.AccessType accessType = clazzToProcess.getAnnotation( org.hibernate.annotations.AccessType.class );
- if ( accessType != null ) {
- hibernateExplicitAccessType = AccessType.getAccessStrategy( accessType.value() );
- }
-
- Access access = clazzToProcess.getAnnotation( Access.class );
- if( access != null ) {
- jpaExplicitAccessType = AccessType.getAccessStrategy( access.value() );
- }
-
- if ( hibernateExplicitAccessType != AccessType.DEFAULT
- && jpaExplicitAccessType != AccessType.DEFAULT
- && hibernateExplicitAccessType != jpaExplicitAccessType ) {
- throw new MappingException( "@AccessType and @Access specified with contradicting values. Use of @Access only is recommended. " );
- }
-
- if(hibernateExplicitAccessType != AccessType.DEFAULT) {
- explicitAccessType = hibernateExplicitAccessType;
- } else {
- explicitAccessType = jpaExplicitAccessType;
- }
- }
- return explicitAccessType;
+ throw new AnnotationException( "No identifier specified for entity: " + annotatedClass.getName() );
}
private static List<XClass> getMappedSuperclassesTillNextEntityOrdered(
@@ -1021,7 +954,7 @@
// classes from 0 to n-1 are @MappedSuperclass and should be linked
org.hibernate.mapping.MappedSuperclass mappedSuperclass = null;
final InheritanceState superEntityState =
- InheritanceState.getInheritanceStateOfSuperEntity(annotatedClass, inheritanceStatePerClass, reflectionManager);
+ InheritanceState.getInheritanceStateOfSuperEntity( annotatedClass, inheritanceStatePerClass );
PersistentClass superEntity =
superEntityState != null ?
mappings.getClass( superEntityState.getClazz().getName() ) :
@@ -1162,7 +1095,7 @@
/**
*
* @param elements List of {@code ProperyData} instances
- * @param propertyAccessor The default value access strategy which has to be used in case no explicit local access
+ * @param defaultAccessType The default value access strategy which has to be used in case no explicit local access
* strategy is used
* @param propertyContainer Metadata about a class and its properties
* @param mappings Mapping meta data
@@ -1170,19 +1103,20 @@
* the determined access strategy, {@code false} otherwise.
*/
private static boolean addElementsOfClass(
- List<PropertyData> elements, AccessType propertyAccessor, PropertyContainer propertyContainer, ExtendedMappings mappings
+ List<PropertyData> elements, AccessType defaultAccessType, PropertyContainer propertyContainer, ExtendedMappings mappings
) {
boolean hasIdentifier = false;
- AccessType classDefinedAccessType = propertyContainer.getDefaultAccessStrategy();
+ AccessType accessType = defaultAccessType;
- if ( classDefinedAccessType.equals( AccessType.DEFAULT ) ) {
- classDefinedAccessType = propertyAccessor;
+ if ( propertyContainer.hasExplicitAccessStrategy() ) {
+ accessType = propertyContainer.getExplicitAccessStrategy();
}
- Collection<XProperty> properties = propertyContainer.getProperties( classDefinedAccessType );
+ propertyContainer.assertTypesAreResolvable( accessType );
+ Collection<XProperty> properties = propertyContainer.getProperties( accessType );
for ( XProperty p : properties ) {
final boolean currentHasIdentifier = addProperty(
- propertyContainer.getXClass(), p, elements, classDefinedAccessType.getType(), mappings
+ propertyContainer.getXClass(), p, elements, accessType.getType(), mappings
);
hasIdentifier = hasIdentifier || currentHasIdentifier;
}
@@ -1193,7 +1127,7 @@
XClass declaringClass, XProperty property, List<PropertyData> annElts,
String propertyAccessor, ExtendedMappings mappings
) {
- boolean hasIdentifier = false;
+ boolean hasIdentifier;
PropertyData propertyAnnotatedElement = new PropertyInferredData(
declaringClass, property, propertyAccessor,
mappings.getReflectionManager() );
@@ -2048,7 +1982,6 @@
List<PropertyData> baseClassElements = null;
XClass baseReturnedClassOrElement;
- PropertyHolder baseSubHolder;
if(baseInferredData != null)
{
baseClassElements = new ArrayList<PropertyData>();
@@ -2567,29 +2500,22 @@
* inheritance status of a class.
*
* @param orderedClasses Order list of all annotated entities and their mapped superclasses
- * @param reflectionManager Reference to the reflection manager (commons-annotations)
* @return A map of {@code InheritanceState}s keyed against their {@code XClass}.
*/
- public static Map<XClass, InheritanceState> buildInheritanceStates(
- List<XClass> orderedClasses, ReflectionManager reflectionManager
- ) {
+ public static Map<XClass, InheritanceState> buildInheritanceStates(List<XClass> orderedClasses) {
Map<XClass, InheritanceState> inheritanceStatePerClass = new HashMap<XClass, InheritanceState>(
orderedClasses.size()
);
for (XClass clazz : orderedClasses) {
InheritanceState superclassState = InheritanceState.getSuperclassInheritanceState(
- clazz, inheritanceStatePerClass,
- reflectionManager
- );
+ clazz, inheritanceStatePerClass );
InheritanceState state = new InheritanceState( clazz );
if ( superclassState != null ) {
//the classes are ordered thus preventing an NPE
//FIXME if an entity has subclasses annotated @MappedSperclass wo sub @Entity this is wrong
superclassState.setHasSiblings( true );
InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity(
- clazz, inheritanceStatePerClass,
- reflectionManager
- );
+ clazz, inheritanceStatePerClass );
state.setHasParents( superEntityState != null );
final boolean nonDefault = state.getType() != null && !InheritanceType.SINGLE_TABLE.equals( state.getType() );
if ( superclassState.getType() != null ) {
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -611,7 +611,7 @@
//bind classes in the correct order calculating some inheritance state
List<XClass> orderedClasses = orderAndFillHierarchy( annotatedClasses );
Map<XClass, InheritanceState> inheritanceStatePerClass = AnnotationBinder.buildInheritanceStates(
- orderedClasses, reflectionManager
+ orderedClasses
);
ExtendedMappings mappings = createExtendedMappings();
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/InheritanceState.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/InheritanceState.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/InheritanceState.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -28,7 +28,6 @@
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
import org.hibernate.annotations.common.reflection.XClass;
@@ -57,11 +56,6 @@
private InheritanceType type;
private boolean isEmbeddableSuperclass = false;
- /**
- * only defined on embedded superclasses
- */
- private AccessType accessType = AccessType.DEFAULT;
-
private void extractInheritanceType() {
XAnnotatedElement element = getClazz();
Inheritance inhAnn = element.getAnnotation( Inheritance.class );
@@ -84,8 +78,7 @@
}
public static InheritanceState getInheritanceStateOfSuperEntity(
- XClass clazz, Map<XClass, InheritanceState> states,
- ReflectionManager reflectionManager
+ XClass clazz, Map<XClass, InheritanceState> states
) {
XClass superclass = clazz;
do {
@@ -95,14 +88,11 @@
return currentState;
}
}
- while ( superclass != null && !reflectionManager.equals( superclass, Object.class ) );
+ while ( superclass != null && !Object.class.getName().equals( superclass.getName() ) );
return null;
}
- public static InheritanceState getSuperclassInheritanceState(
- XClass clazz, Map<XClass, InheritanceState> states,
- ReflectionManager reflectionManager
- ) {
+ public static InheritanceState getSuperclassInheritanceState( XClass clazz, Map<XClass, InheritanceState> states) {
XClass superclass = clazz;
do {
superclass = superclass.getSuperclass();
@@ -111,7 +101,7 @@
return currentState;
}
}
- while ( superclass != null && !reflectionManager.equals( superclass, Object.class ) );
+ while ( superclass != null && !Object.class.getName().equals( superclass.getName() ) );
return null;
}
@@ -154,12 +144,4 @@
public void setEmbeddableSuperclass(boolean embeddableSuperclass) {
isEmbeddableSuperclass = embeddableSuperclass;
}
-
- public AccessType getAccessType() {
- return accessType;
- }
-
- public void setAccessType(AccessType type) {
- this.accessType = type;
- }
}
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyContainer.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyContainer.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyContainer.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -45,40 +45,41 @@
import org.hibernate.annotations.Type;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.util.StringHelper;
/**
+ * A helper class to keep the {@code XProperty}s of a class ordered by access type.
+ *
* @author Hardy Ferentschik
*/
-
-/**
- * A temporary class where we keep the {@code XProperty}s of a class ordered by access type.
- */
class PropertyContainer {
private static final Logger log = LoggerFactory.getLogger( AnnotationBinder.class );
private final TreeMap<String, XProperty> fieldAccessMap;
private final TreeMap<String, XProperty> propertyAccessMap;
private final XClass xClass;
- private final AccessType defaultAccessType;
+ private final AccessType explicitClassDefinedAccessType;
PropertyContainer(XClass clazz) {
this.xClass = clazz;
fieldAccessMap = initProperties( AccessType.FIELD );
propertyAccessMap = initProperties( AccessType.PROPERTY );
- defaultAccessType = determineClassDefinedAccessStrategy();
+ explicitClassDefinedAccessType = determineClassDefinedAccessStrategy();
checkForJpaAccess();
-
-
}
public XClass getXClass() {
return xClass;
}
- public AccessType getDefaultAccessStrategy() {
- return defaultAccessType;
+ public AccessType getExplicitAccessStrategy() {
+ return explicitClassDefinedAccessType;
}
+ public boolean hasExplicitAccessStrategy() {
+ return !explicitClassDefinedAccessType.equals( AccessType.DEFAULT );
+ }
+
public Collection<XProperty> getProperties(AccessType accessType) {
if ( AccessType.DEFAULT == accessType || AccessType.PROPERTY == accessType ) {
return propertyAccessMap.values();
@@ -88,6 +89,24 @@
}
}
+ public void assertTypesAreResolvable(AccessType access) {
+ TreeMap<String, XProperty> xprops;
+ if ( AccessType.PROPERTY.equals( access ) || AccessType.DEFAULT.equals( access ) ) {
+ xprops = propertyAccessMap;
+ }
+ else {
+ xprops = fieldAccessMap;
+ }
+ for ( XProperty property : xprops.values() ) {
+ if ( !property.isTypeResolved() && !discoverTypeWithoutReflection( property ) ) {
+ String msg = "Property " + StringHelper.qualify( xClass.getName(), property.getName() ) +
+ " has an unbound type and no explicit target entity. Resolve this Generic usage issue" +
+ " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type";
+ throw new AnnotationException( msg );
+ }
+ }
+ }
+
private void checkForJpaAccess() {
List<XProperty> tmpList = new ArrayList<XProperty>();
for ( XProperty property : fieldAccessMap.values() ) {
@@ -136,16 +155,10 @@
TreeMap<String, XProperty> propertiesMap = new TreeMap<String, XProperty>();
List<XProperty> properties = xClass.getDeclaredProperties( access.getType() );
for ( XProperty property : properties ) {
-// if ( !property.isTypeResolved() && !discoverTypeWithoutReflection( property )
-// && !mustBeSkipped( property ) ) {
-// String msg = "Property " + StringHelper.qualify( xClass.getName(), property.getName() ) +
-// " has an unbound type and no explicit target entity. Resolve this Generic usage issue" +
-// " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type";
-// throw new AnnotationException( msg );
-// }
- if ( !mustBeSkipped( property ) ) {
- propertiesMap.put( property.getName(), property );
+ if ( mustBeSkipped( property ) ) {
+ continue;
}
+ propertiesMap.put( property.getName(), property );
}
return propertiesMap;
}
Property changes on: core/trunk/annotations/src/main/java/org/hibernate/cfg/PropertyContainer.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -118,7 +118,7 @@
private InheritanceState inheritanceState;
private boolean ignoreIdAnnotations;
private boolean cacheLazyProperty;
- private AccessType propertyAccessor = AccessType.DEFAULT;
+ private AccessType propertyAccessType = AccessType.DEFAULT;
/**
* Use as a fake one for Collection of elements
@@ -843,17 +843,29 @@
}
}
- public AccessType getPropertyAccessor() {
- return propertyAccessor;
+ public AccessType getPropertyAccessType() {
+ return propertyAccessType;
}
- public void setPropertyAccessor(AccessType propertyAccessor) {
- this.propertyAccessor = propertyAccessor;
+ public void setPropertyAccessType(AccessType propertyAccessor) {
+ this.propertyAccessType = getExplicitAccessType( annotatedClass );
+ // only set the access type if there is no explicit access type for this class
+ if( this.propertyAccessType == null ) {
+ this.propertyAccessType = propertyAccessor;
+ }
}
public AccessType getPropertyAccessor(XAnnotatedElement element) {
- AccessType accessType = propertyAccessor;
+ AccessType accessType = getExplicitAccessType( element );
+ if ( accessType == null ) {
+ accessType = propertyAccessType;
+ }
+ return accessType;
+ }
+ public AccessType getExplicitAccessType(XAnnotatedElement element) {
+ AccessType accessType = null;
+
AccessType hibernateAccessType = null;
AccessType jpaAccessType = null;
@@ -868,7 +880,9 @@
}
if ( hibernateAccessType != null && jpaAccessType != null && hibernateAccessType != jpaAccessType ) {
- throw new MappingException( " " );
+ throw new MappingException(
+ "Found @Access and @AccessType with conflicting values on a property in class " + annotatedClass.toString()
+ );
}
if ( hibernateAccessType != null ) {
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -43,7 +43,7 @@
public void testInconsistentAnnotationPlacement() throws Exception {
AnnotationConfiguration cfg = new AnnotationConfiguration();
- cfg.addAnnotatedClass( Course.class );
+ cfg.addAnnotatedClass( Course1.class );
cfg.addAnnotatedClass( Student.class );
try {
cfg.buildSessionFactory();
@@ -56,7 +56,7 @@
public void testFieldAnnotationPlacement() throws Exception {
AnnotationConfiguration cfg = new AnnotationConfiguration();
- Class<?> classUnderTest = CourseFieldAccess.class;
+ Class<?> classUnderTest = Course6.class;
cfg.addAnnotatedClass( classUnderTest );
cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
@@ -71,7 +71,7 @@
public void testPropertyAnnotationPlacement() throws Exception {
AnnotationConfiguration cfg = new AnnotationConfiguration();
- Class<?> classUnderTest = CoursePropertyAccess.class;
+ Class<?> classUnderTest = Course7.class;
cfg.addAnnotatedClass( classUnderTest );
cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
@@ -86,7 +86,7 @@
public void testExplicitPropertyAccessAnnotationsOnProperty() throws Exception {
AnnotationConfiguration cfg = new AnnotationConfiguration();
- Class<?> classUnderTest = CourseExplicitPropertyAccess.class;
+ Class<?> classUnderTest = Course2.class;
cfg.addAnnotatedClass( classUnderTest );
cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
@@ -101,7 +101,7 @@
public void testExplicitPropertyAccessAnnotationsOnField() throws Exception {
AnnotationConfiguration cfg = new AnnotationConfiguration();
- cfg.addAnnotatedClass( CourseExplicitPropertyAccess3.class );
+ cfg.addAnnotatedClass( Course4.class );
cfg.addAnnotatedClass( Student.class );
try {
cfg.buildSessionFactory();
@@ -114,7 +114,7 @@
public void testExplicitPropertyAccessAnnotationsWithHibernateStyleOverride() throws Exception {
AnnotationConfiguration cfg = new AnnotationConfiguration();
- Class<?> classUnderTest = CourseExplicitPropertyAccess2.class;
+ Class<?> classUnderTest = Course3.class;
cfg.addAnnotatedClass( classUnderTest );
cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
@@ -134,7 +134,7 @@
public void testExplicitPropertyAccessAnnotationsWithJpaStyleOverride() throws Exception {
AnnotationConfiguration cfg = new AnnotationConfiguration();
- Class<?> classUnderTest = CourseExplicitPropertyAccess4.class;
+ Class<?> classUnderTest = Course5.class;
cfg.addAnnotatedClass( classUnderTest );
cfg.addAnnotatedClass( Student.class );
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
@@ -151,4 +151,43 @@
tuplizer.getGetter( 0 ) instanceof BasicPropertyAccessor.BasicGetter
);
}
+
+ public void testDefaultFieldAccessIsInherited() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ Class<?> classUnderTest = User.class;
+ cfg.addAnnotatedClass( classUnderTest );
+ cfg.addAnnotatedClass( Person.class );
+ cfg.addAnnotatedClass( Being.class );
+ SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
+ EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
+ .getEntityMetamodel();
+ PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
+ assertTrue(
+ "Field access should be used since the default access mode gets inherited",
+ tuplizer.getIdentifierGetter() instanceof DirectPropertyAccessor.DirectGetter
+ );
+ }
+
+ public void testDefaultPropertyAccessIsInherited() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ cfg.addAnnotatedClass( Horse.class );
+ cfg.addAnnotatedClass( Animal.class );
+
+ SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
+ EntityMetamodel metaModel = factory.getEntityPersister( Animal.class.getName() )
+ .getEntityMetamodel();
+ PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
+ assertTrue(
+ "Property access should be used since explicity configured via @Access",
+ tuplizer.getIdentifierGetter() instanceof BasicPropertyAccessor.BasicGetter
+ );
+
+ metaModel = factory.getEntityPersister( Horse.class.getName() )
+ .getEntityMetamodel();
+ tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
+ assertTrue(
+ "Property access should be used since the default access mode gets inherited",
+ tuplizer.getGetter( 0 ) instanceof BasicPropertyAccessor.BasicGetter
+ );
+ }
}
\ No newline at end of file
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/AccessTest.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -54,10 +54,10 @@
tx.commit();
s.clear();
tx = s.beginTransaction();
- john = (User) s.get( User.class, john.getId() );
- assertEquals("Wrong number of friends", 1, john.getFriends().size() );
+ john = ( User ) s.get( User.class, john.getId() );
+ assertEquals( "Wrong number of friends", 1, john.getFriends().size() );
assertNull( john.firstname );
-
+
s.delete( john );
tx.commit();
s.close();
@@ -74,7 +74,7 @@
tx.commit();
s.clear();
tx = s.beginTransaction();
- fur = (Furniture) s.get( Furniture.class, fur.getId() );
+ fur = ( Furniture ) s.get( Furniture.class, fur.getId() );
assertFalse( fur.isAlive );
assertNotNull( fur.getColor() );
s.delete( fur );
@@ -91,7 +91,7 @@
tx.commit();
s.clear();
tx = s.beginTransaction();
- fur = (Furniture) s.get( Furniture.class, fur.getId() );
+ fur = ( Furniture ) s.get( Furniture.class, fur.getId() );
assertNotNull( fur.getGod() );
s.delete( fur );
tx.commit();
@@ -107,7 +107,7 @@
tx.commit();
s.clear();
tx = s.beginTransaction();
- fur = (Furniture) s.get( Furniture.class, fur.getId() );
+ fur = ( Furniture ) s.get( Furniture.class, fur.getId() );
assertEquals( 5, fur.weight );
s.delete( fur );
tx.commit();
@@ -124,7 +124,7 @@
tx.commit();
s.clear();
tx = s.beginTransaction();
- chair = (Chair) s.get( Chair.class, chair.getId() );
+ chair = ( Chair ) s.get( Chair.class, chair.getId() );
assertNull( chair.getPillow() );
s.delete( chair );
tx.commit();
@@ -142,7 +142,7 @@
tx.commit();
s.clear();
tx = s.beginTransaction();
- bed = (BigBed) s.get( BigBed.class, bed.getId() );
+ bed = ( BigBed ) s.get( BigBed.class, bed.getId() );
assertEquals( 5, bed.size );
assertNull( bed.getQuality() );
s.delete( bed );
@@ -160,7 +160,7 @@
tx.commit();
s.clear();
tx = s.beginTransaction();
- gs = (Gardenshed) s.get( Gardenshed.class, gs.getId() );
+ gs = ( Gardenshed ) s.get( Gardenshed.class, gs.getId() );
assertEquals( 4, gs.floors );
assertEquals( 6, gs.getFloors() );
s.delete( gs );
@@ -169,6 +169,29 @@
}
+ public void testEmbeddableUsesAccessStrategyOfContainingClass() throws Exception {
+ Circle circle = new Circle();
+ Color color = new Color( 5, 10, 15 );
+ circle.setColor( color );
+ Session s = openSession();
+ s.persist( circle );
+ Transaction tx = s.beginTransaction();
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ circle = ( Circle ) s.get( Circle.class, circle.getId() );
+ assertEquals( 5, circle.getColor().r );
+ try {
+ circle.getColor().getR();
+ fail();
+ } catch (RuntimeException e) {
+ // success
+ }
+ s.delete( circle );
+ tx.commit();
+ s.close();
+ }
+
protected Class[] getMappings() {
return new Class[] {
Bed.class,
@@ -178,7 +201,10 @@
Gardenshed.class,
Closet.class,
Person.class,
- User.class
+ User.class,
+ Shape.class,
+ Circle.class,
+ Color.class
};
}
}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Animal.java (from rev 18386, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Being.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Animal.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Animal.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,53 @@
+//$Id$
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.FIELD)
+public class Animal {
+
+ private long id;
+
+ @Access( AccessType.PROPERTY)
+ @Id
+ @GeneratedValue
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+}
\ No newline at end of file
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Circle.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Circle.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Circle.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,49 @@
+//$Id: Being.java 18260 2009-12-17 21:14:07Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.FIELD)
+public class Circle extends Shape {
+ @Embedded
+ private Color color;
+
+ public Color getColor() {
+ return color;
+ }
+
+ public void setColor(Color color) {
+ this.color = color;
+ }
+}
\ No newline at end of file
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Color.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Color.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Color.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,71 @@
+//$Id: Being.java 18260 2009-12-17 21:14:07Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Embeddable;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Embeddable
+public class Color {
+ public int r;
+ public int g;
+ public int b;
+
+ public Color() {
+ }
+
+ public Color(int r, int g, int b) {
+ this.r = r;
+ this.g = g;
+ this.b = b;
+ }
+
+ public int getB() {
+ throw new RuntimeException();
+ }
+
+ public void setB(int b) {
+ this.b = b;
+ }
+
+ public int getG() {
+ throw new RuntimeException();
+ }
+
+ public void setG(int g) {
+ this.g = g;
+ }
+
+ public int getR() {
+ throw new RuntimeException();
+ }
+
+ public void setR(int r) {
+ this.r = r;
+ }
+}
\ No newline at end of file
Deleted: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -1,74 +0,0 @@
-//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.annotations.access.jpa;
-
-import java.util.List;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-public class Course {
- @Id
- @GeneratedValue
- private long id;
-
- private String title;
-
- private List<Student> students;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- @OneToMany(cascade = CascadeType.ALL)
- public List<Student> getStudents() {
- return students;
- }
-
- public void setStudents(List<Student> students) {
- this.students = students;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-}
-
-
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course1.java (from rev 18410, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course1.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course1.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,74 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Course1 {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String title;
+
+ private List<Student> students;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL)
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
+
+
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course2.java (from rev 18410, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course2.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course2.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,75 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.PROPERTY)
+public class Course2 {
+ private long id;
+
+ private String title;
+
+ private List<Student> students;
+
+ @Id
+ @GeneratedValue
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL)
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course3.java (from rev 18410, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess2.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course3.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course3.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,77 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.PROPERTY)
+public class Course3 {
+ private long id;
+
+ private String title;
+
+
+ private List<Student> students;
+
+ @Id
+ @GeneratedValue
+ @org.hibernate.annotations.AccessType("field")
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL)
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course4.java (from rev 18410, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess3.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course4.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course4.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,75 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.PROPERTY)
+public class Course4 {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String title;
+
+ @OneToMany(cascade = CascadeType.ALL)
+ private List<Student> students;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course5.java (from rev 18410, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess4.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course5.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course5.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,77 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)Access(AccessType.PROPERTY)
+public class Course5 {
+
+ @Access(AccessType.FIELD)
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String title;
+
+ private List<Student> students;
+
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @ManyToMany
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course6.java (from rev 18410, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseFieldAccess.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course6.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course6.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,72 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Course6 {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String title;
+
+ @OneToMany(cascade = CascadeType.ALL)
+ private List<Student> students;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Copied: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course7.java (from rev 18410, core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CoursePropertyAccess.java)
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course7.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Course7.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,72 @@
+//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import java.util.List;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Course7 {
+ private long id;
+
+ private String title;
+
+ private List<Student> students;
+
+ @Id
+ @GeneratedValue
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL)
+ public List<Student> getStudents() {
+ return students;
+ }
+
+ public void setStudents(List<Student> students) {
+ this.students = students;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
\ No newline at end of file
Deleted: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -1,75 +0,0 @@
-//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.annotations.access.jpa;
-
-import java.util.List;
-import javax.persistence.Access;
-import javax.persistence.AccessType;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-(a)Access(AccessType.PROPERTY)
-public class CourseExplicitPropertyAccess {
- private long id;
-
- private String title;
-
- private List<Student> students;
-
- @Id
- @GeneratedValue
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- @OneToMany(cascade = CascadeType.ALL)
- public List<Student> getStudents() {
- return students;
- }
-
- public void setStudents(List<Student> students) {
- this.students = students;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-}
\ No newline at end of file
Deleted: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess2.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess2.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess2.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -1,77 +0,0 @@
-//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.annotations.access.jpa;
-
-import java.util.List;
-import javax.persistence.Access;
-import javax.persistence.AccessType;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-(a)Access(AccessType.PROPERTY)
-public class CourseExplicitPropertyAccess2 {
- private long id;
-
- private String title;
-
-
- private List<Student> students;
-
- @Id
- @GeneratedValue
- @org.hibernate.annotations.AccessType("field")
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- @OneToMany(cascade = CascadeType.ALL)
- public List<Student> getStudents() {
- return students;
- }
-
- public void setStudents(List<Student> students) {
- this.students = students;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-}
\ No newline at end of file
Deleted: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess3.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess3.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess3.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -1,75 +0,0 @@
-//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.annotations.access.jpa;
-
-import java.util.List;
-import javax.persistence.Access;
-import javax.persistence.AccessType;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-(a)Access(AccessType.PROPERTY)
-public class CourseExplicitPropertyAccess3 {
- @Id
- @GeneratedValue
- private long id;
-
- private String title;
-
- @OneToMany(cascade = CascadeType.ALL)
- private List<Student> students;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public List<Student> getStudents() {
- return students;
- }
-
- public void setStudents(List<Student> students) {
- this.students = students;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-}
\ No newline at end of file
Deleted: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess4.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess4.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseExplicitPropertyAccess4.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -1,77 +0,0 @@
-//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.annotations.access.jpa;
-
-import java.util.List;
-import javax.persistence.Access;
-import javax.persistence.AccessType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToMany;
-
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-(a)Access(AccessType.PROPERTY)
-public class CourseExplicitPropertyAccess4 {
-
- @Access(AccessType.FIELD)
- @Id
- @GeneratedValue
- private long id;
-
- private String title;
-
- private List<Student> students;
-
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- @ManyToMany
- public List<Student> getStudents() {
- return students;
- }
-
- public void setStudents(List<Student> students) {
- this.students = students;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-}
\ No newline at end of file
Deleted: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseFieldAccess.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseFieldAccess.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CourseFieldAccess.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -1,72 +0,0 @@
-//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.annotations.access.jpa;
-
-import java.util.List;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-public class CourseFieldAccess {
- @Id
- @GeneratedValue
- private long id;
-
- private String title;
-
- @OneToMany(cascade = CascadeType.ALL)
- private List<Student> students;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public List<Student> getStudents() {
- return students;
- }
-
- public void setStudents(List<Student> students) {
- this.students = students;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-}
\ No newline at end of file
Deleted: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CoursePropertyAccess.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CoursePropertyAccess.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/CoursePropertyAccess.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -1,72 +0,0 @@
-//$Id: AccessTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.annotations.access.jpa;
-
-import java.util.List;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-
-
-/**
- * @author Hardy Ferentschik
- */
-@Entity
-public class CoursePropertyAccess {
- private long id;
-
- private String title;
-
- private List<Student> students;
-
- @Id
- @GeneratedValue
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- @OneToMany(cascade = CascadeType.ALL)
- public List<Student> getStudents() {
- return students;
- }
-
- public void setStudents(List<Student> students) {
- this.students = students;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-}
\ No newline at end of file
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Furniture.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Furniture.java 2010-01-05 18:50:48 UTC (rev 18416)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Furniture.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -1,4 +1,4 @@
-//$Id:$
+//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@@ -59,9 +59,9 @@
this.id = id;
}
- @Access(javax.persistence.AccessType.PROPERTY)
public long weight;
+ @Access(javax.persistence.AccessType.PROPERTY)
public long getWeight() {
return weight + 1;
}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Horse.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Horse.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Horse.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,45 @@
+//$Id: Being.java 18260 2009-12-17 21:14:07Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Entity;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Horse extends Animal {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Shape.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Shape.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa/Shape.java 2010-01-05 21:51:35 UTC (rev 18417)
@@ -0,0 +1,50 @@
+//$Id: Being.java 18260 2009-12-17 21:14:07Z hardy.ferentschik $
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.access.jpa;
+
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Shape {
+ private long id;
+
+ @Id
+ @GeneratedValue
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+}
\ No newline at end of file
14 years, 11 months
Hibernate SVN: r18416 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity.
by hibernate-commits@lists.jboss.org
Author: smarlow(a)redhat.com
Date: 2010-01-05 13:50:48 -0500 (Tue, 05 Jan 2010)
New Revision: 18416
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Forest.java
Log:
HHH-4684 Make sure @Lob works with @ElementCollection
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2010-01-05 18:00:34 UTC (rev 18415)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2010-01-05 18:50:48 UTC (rev 18416)
@@ -27,6 +27,9 @@
import java.math.BigDecimal;
import java.util.Currency;
import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
import org.hibernate.AnnotationException;
import org.hibernate.Hibernate;
@@ -469,6 +472,17 @@
Country country = new Country();
country.setName( "Middle Earth" );
forest.setCountry( country );
+ Set<Country> near = new HashSet<Country>();
+ country = new Country();
+ country.setName("Mordor");
+ near.add(country);
+ country = new Country();
+ country.setName("Gondor");
+ near.add(country);
+ country = new Country();
+ country.setName("Eriador");
+ near.add(country);
+ forest.setNear(near);
Session s;
Transaction tx;
s = openSession();
@@ -481,8 +495,17 @@
tx = s.beginTransaction();
forest = (Forest) s.get( Forest.class, forest.getId() );
assertNotNull( forest );
- assertNotNull( forest.getCountry() );
+ country = forest.getCountry();
+ assertNotNull( country );
assertEquals( country.getName(), forest.getCountry().getName() );
+ near = forest.getNear();
+ assertTrue("correct number of nearby countries", near.size() == 3);
+ for (Iterator iter = near.iterator(); iter.hasNext();) {
+ country = (Country)iter.next();
+ String name = country.getName();
+ assertTrue("found expected nearby country " + name,
+ (name.equals("Mordor") || name.equals("Gondor") || name.equals("Eriador")));
+ }
tx.commit();
s.close();
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Forest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Forest.java 2010-01-05 18:00:34 UTC (rev 18415)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Forest.java 2010-01-05 18:50:48 UTC (rev 18416)
@@ -1,6 +1,7 @@
//$Id$
package org.hibernate.test.annotations.entity;
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@@ -19,6 +20,8 @@
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
+import java.util.Set;
+
/**
* Use hibernate specific annotations
*
@@ -47,6 +50,7 @@
private String smallText;
private String bigText;
private Country country;
+ private Set near;
@OptimisticLock(excluded=true)
@Type(type = "text")
@@ -110,4 +114,15 @@
public void setCountry(Country country) {
this.country = country;
}
+
+ @Lob
+ @ElementCollection
+ public Set<Country> getNear() {
+ return near;
+ }
+
+ public void setNear(Set<Country>near) {
+ this.near = near;
+ }
+
}
14 years, 11 months
Hibernate SVN: r18415 - core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-01-05 13:00:34 -0500 (Tue, 05 Jan 2010)
New Revision: 18415
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/TableBinder.java
Log:
HHH-4753 Default table name for @CollectionTable is not inferred correctly according to spec requirement. Legacy names still supported. Fixing NPE in some cases
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/TableBinder.java 2010-01-05 16:55:15 UTC (rev 18414)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/TableBinder.java 2010-01-05 18:00:34 UTC (rev 18415)
@@ -144,7 +144,9 @@
final String unquotedAssocTable = StringHelper.unquote( associatedEntityTable );
//@ElementCollection use ownerEntity_property instead of the cleaner ownerTableName_property
- final String ownerObjectName = isJPA2ElementCollection ? StringHelper.unqualify( ownerEntity ) : unquotedOwnerTable;
+ // ownerEntity can be null when the table name is explicitly set
+ final String ownerObjectName = isJPA2ElementCollection && ownerEntity != null ?
+ StringHelper.unqualify( ownerEntity ) : unquotedOwnerTable;
final ObjectNameSource nameSource = buildNameContext(
ownerObjectName,
unquotedAssocTable );
14 years, 11 months
Hibernate SVN: r18414 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement.
by hibernate-commits@lists.jboss.org
Author: smarlow(a)redhat.com
Date: 2010-01-05 11:55:15 -0500 (Tue, 05 Jan 2010)
New Revision: 18414
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/FavoriteFood.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
Log:
HHH-4683 Make sure @Enumerated works with @ElementCollection. Added Map test.
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java 2010-01-05 16:11:14 UTC (rev 18413)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java 2010-01-05 16:55:15 UTC (rev 18414)
@@ -20,6 +20,7 @@
import javax.persistence.OrderColumn;
import org.hibernate.annotations.CollectionOfElements;
+import org.hibernate.test.annotations.collectionelement.FavoriteFood;
/**
* @author Emmanuel Bernard
@@ -39,6 +40,7 @@
private int[] favoriteNumbers;
private Set<Toy> favoriteToys = new HashSet<Toy>();
private Set<Character> characters = new HashSet<Character>();
+ private Map<String, FavoriteFood> foods = new HashMap<String,FavoriteFood>();
private Set<CountryAttitude> countryAttitudes = new HashSet<CountryAttitude>();
@Id
@@ -122,6 +124,16 @@
this.characters = characters;
}
+ @ElementCollection
+ @Enumerated(EnumType.STRING)
+ public Map<String, FavoriteFood> getFavoriteFood() {
+ return foods;
+ }
+
+ public void setFavoriteFood(Map<String, FavoriteFood>foods) {
+ this.foods = foods;
+ }
+
@ElementCollection(fetch = FetchType.EAGER)
//@Where(clause = "b_likes=false")
public Set<CountryAttitude> getCountryAttitudes() {
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java 2010-01-05 16:11:14 UTC (rev 18413)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java 2010-01-05 16:55:15 UTC (rev 18414)
@@ -1,6 +1,7 @@
//$Id$
package org.hibernate.test.annotations.collectionelement;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -40,6 +41,12 @@
boy.setFavoriteNumbers( favNbrs );
boy.getCharacters().add( Character.GENTLE );
boy.getCharacters().add( Character.CRAFTY );
+
+ HashMap<String,FavoriteFood> foods = new HashMap<String,FavoriteFood>();
+ foods.put( "breakfast", FavoriteFood.PIZZA);
+ foods.put( "lunch", FavoriteFood.KUNGPAOCHICKEN);
+ foods.put( "dinner", FavoriteFood.SUSHI);
+ boy.setFavoriteFood(foods);
s.persist( boy );
s.getTransaction().commit();
s.clear();
@@ -53,6 +60,9 @@
assertNotNull( boy.getFavoriteNumbers() );
assertEquals( 3, boy.getFavoriteNumbers()[1] );
assertTrue( boy.getCharacters().contains( Character.CRAFTY ) );
+ assertTrue( boy.getFavoriteFood().get("dinner").equals(FavoriteFood.SUSHI));
+ assertTrue( boy.getFavoriteFood().get("lunch").equals(FavoriteFood.KUNGPAOCHICKEN));
+ assertTrue( boy.getFavoriteFood().get("breakfast").equals(FavoriteFood.PIZZA));
List result = s.createQuery( "select boy from Boy boy join boy.nickNames names where names = :name" )
.setParameter( "name", "Thing" ).list();
assertEquals( 1, result.size() );
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/FavoriteFood.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/FavoriteFood.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/FavoriteFood.java 2010-01-05 16:55:15 UTC (rev 18414)
@@ -0,0 +1,8 @@
+package org.hibernate.test.annotations.collectionelement;
+
+public enum FavoriteFood {
+ SUSHI,
+ KUNGPAOCHICKEN,
+ ROASTBEEF,
+ PIZZA
+}
14 years, 11 months