[hibernate-commits] Hibernate SVN: r18418 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/jpa.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Jan 6 09:37:39 EST 2010


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
+ */
+ at Embeddable
+ at 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
+ */
+ at 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



More information about the hibernate-commits mailing list