Hibernate SVN: r17735 - in annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id: entities and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-10-14 01:15:33 -0400 (Wed, 14 Oct 2009)
New Revision: 17735
Added:
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/EnumIdTest.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdClassTest.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdTest.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Ball.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Computer.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Department.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Dog.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FirTree.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Footballer.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Furniture.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Home.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Location.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Monkey.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Phone.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Planet.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Shoe.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Store.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tower.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tree.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/package-info.java
Modified:
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/IdTest.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Department.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Phone.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Shoe.java
annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Store.java
Log:
JBPAPP-1061 HHH-4397 Tests using sequences are run on databases which doesn't supports sequences
Modified: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/IdTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/IdTest.java 2009-10-14 04:18:35 UTC (rev 17734)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/IdTest.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -28,7 +28,6 @@
*/
@SuppressWarnings("unchecked")
public class IdTest extends TestCase {
- // FIXME split Sequence and Id tests to explicit the run failure on Oracle etc
public void testGenericGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
Modified: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Department.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Department.java 2009-10-14 04:18:35 UTC (rev 17734)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Department.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -2,9 +2,9 @@
package org.hibernate.test.annotations.id.entities;
import java.io.Serializable;
+
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
@@ -18,11 +18,7 @@
private Long id;
@Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_DEPT")
- @javax.persistence.SequenceGenerator(
- name = "SEQ_DEPT",
- sequenceName = "my_sequence"
- )
+ @GeneratedValue
public Long getId() {
return id;
}
Modified: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Phone.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Phone.java 2009-10-14 04:18:35 UTC (rev 17734)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Phone.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -3,7 +3,6 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
@@ -14,11 +13,7 @@
private Integer id;
@Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Phone_Gen")
- @javax.persistence.SequenceGenerator(
- name = "Phone_Gen",
- sequenceName = "phone_seq"
- )
+ @GeneratedValue
public Integer getId() {
return id;
}
Modified: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Shoe.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Shoe.java 2009-10-14 04:18:35 UTC (rev 17734)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Shoe.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -2,9 +2,9 @@
package org.hibernate.test.annotations.id.entities;
import java.io.Serializable;
+
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
@@ -18,7 +18,7 @@
private Long id;
@Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN")
+ @GeneratedValue
public Long getId() {
return id;
}
Modified: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Store.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Store.java 2009-10-14 04:18:35 UTC (rev 17734)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/entities/Store.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -2,9 +2,9 @@
package org.hibernate.test.annotations.id.entities;
import java.io.Serializable;
+
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
@@ -13,16 +13,12 @@
* @author Emmanuel Bernard
*/
@Entity
-(a)javax.persistence.SequenceGenerator(
- name = "SEQ_STORE",
- sequenceName = "my_sequence"
-)
@SuppressWarnings("serial")
public class Store implements Serializable {
private Long id;
@Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
+ @GeneratedValue
public Long getId() {
return id;
}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/EnumIdTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/EnumIdTest.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/EnumIdTest.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,62 @@
+//$Id: EnumIdTest.java 14785 2008-06-19 10:44:33Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.entities.Planet;
+import org.hibernate.test.annotations.id.entities.PlanetCheatSheet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tests for enum type as id.
+ *
+ * @author Hardy Ferentschik
+ * @see ANN-744
+ */
+@SuppressWarnings("unchecked")
+public class EnumIdTest extends TestCase {
+
+ private Logger log = LoggerFactory.getLogger(EnumIdTest.class);
+
+ public EnumIdTest(String x) {
+ super(x);
+ }
+
+ public void testEnumAsId() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ PlanetCheatSheet mercury = new PlanetCheatSheet();
+ mercury.setPlanet(Planet.MERCURY);
+ mercury.setMass(3.303e+23);
+ mercury.setRadius(2.4397e6);
+ mercury.setNumberOfInhabitants(0);
+ s.persist(mercury);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ PlanetCheatSheet mercuryFromDb = (PlanetCheatSheet) s.get(PlanetCheatSheet.class, mercury.getPlanet());
+ assertNotNull(mercuryFromDb);
+ log.debug(mercuryFromDb.toString());
+ s.delete(mercuryFromDb);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ mercury = (PlanetCheatSheet) s.get(PlanetCheatSheet.class, Planet.MERCURY);
+ assertNull(mercury);
+ tx.commit();
+ s.close();
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getMappings()
+ */
+ protected Class[] getMappings() {
+ return new Class[] { PlanetCheatSheet.class };
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdClassTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdClassTest.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdClassTest.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,38 @@
+//$Id: IdClassTest.java 14784 2008-06-19 10:42:20Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.entities.Location;
+import org.hibernate.test.annotations.id.entities.Tower;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@SuppressWarnings("unchecked")
+public class IdClassTest extends TestCase {
+
+ public void testIdClassInSuperclass() throws Exception {
+ Tower tower = new Tower();
+ tower.latitude = 10.3;
+ tower.longitude = 45.4;
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( tower );
+ s.flush();
+ s.clear();
+ Location loc = new Location();
+ loc.latitude = tower.latitude;
+ loc.longitude = tower.longitude;
+ assertNotNull( s.get( Tower.class, loc ) );
+ tx.rollback();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[]{
+ Tower.class
+ };
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdTest.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdTest.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,308 @@
+//$Id: IdTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.mapping.Column;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.sequences.entities.Ball;
+import org.hibernate.test.annotations.id.sequences.entities.BreakDance;
+import org.hibernate.test.annotations.id.sequences.entities.Computer;
+import org.hibernate.test.annotations.id.sequences.entities.Department;
+import org.hibernate.test.annotations.id.sequences.entities.Dog;
+import org.hibernate.test.annotations.id.sequences.entities.FirTree;
+import org.hibernate.test.annotations.id.sequences.entities.Footballer;
+import org.hibernate.test.annotations.id.sequences.entities.FootballerPk;
+import org.hibernate.test.annotations.id.sequences.entities.Furniture;
+import org.hibernate.test.annotations.id.sequences.entities.GoalKeeper;
+import org.hibernate.test.annotations.id.sequences.entities.Home;
+import org.hibernate.test.annotations.id.sequences.entities.Monkey;
+import org.hibernate.test.annotations.id.sequences.entities.Phone;
+import org.hibernate.test.annotations.id.sequences.entities.Shoe;
+import org.hibernate.test.annotations.id.sequences.entities.SoundSystem;
+import org.hibernate.test.annotations.id.sequences.entities.Store;
+import org.hibernate.test.annotations.id.sequences.entities.Tree;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@SuppressWarnings("unchecked")
+public class IdTest extends TestCase {
+ public void testGenericGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ SoundSystem system = new SoundSystem();
+ system.setBrand("Genelec");
+ system.setModel("T234");
+ Furniture fur = new Furniture();
+ s.persist(system);
+ s.persist(fur);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ system = (SoundSystem) s.get(SoundSystem.class, system.getId());
+ fur = (Furniture) s.get(Furniture.class, fur.getId());
+ assertNotNull(system);
+ assertNotNull(fur);
+ s.delete(system);
+ s.delete(fur);
+ tx.commit();
+ s.close();
+
+ }
+
+ /*
+ * Ensures that GenericGenerator annotations wrapped inside a
+ * GenericGenerators holder are bound correctly
+ */
+ public void testGenericGenerators() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Monkey monkey = new Monkey();
+ s.persist(monkey);
+ s.flush();
+ assertNotNull(monkey.getId());
+ tx.rollback();
+ s.close();
+ }
+
+ public void testTableGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+
+ Ball b = new Ball();
+ Dog d = new Dog();
+ Computer c = new Computer();
+ s.persist(b);
+ s.persist(d);
+ s.persist(c);
+ tx.commit();
+ s.close();
+ assertEquals("table id not generated", new Integer(1), b.getId());
+ assertEquals("generator should not be shared", new Integer(1), d
+ .getId());
+ assertEquals("default value should work", new Long(1), c.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete(s.get(Ball.class, new Integer(1)));
+ s.delete(s.get(Dog.class, new Integer(1)));
+ s.delete(s.get(Computer.class, new Long(1)));
+ tx.commit();
+ s.close();
+ }
+
+ public void testSequenceGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Shoe b = new Shoe();
+ s.persist(b);
+ tx.commit();
+ s.close();
+ assertNotNull(b.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete(s.get(Shoe.class, b.getId()));
+ tx.commit();
+ s.close();
+ }
+
+ public void testClassLevelGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Store b = new Store();
+ s.persist(b);
+ tx.commit();
+ s.close();
+ assertNotNull(b.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete(s.get(Store.class, b.getId()));
+ tx.commit();
+ s.close();
+ }
+
+ public void testMethodLevelGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Department b = new Department();
+ s.persist(b);
+ tx.commit();
+ s.close();
+ assertNotNull(b.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete(s.get(Department.class, b.getId()));
+ tx.commit();
+ s.close();
+ }
+
+ public void testDefaultSequence() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Home h = new Home();
+ s.persist(h);
+ tx.commit();
+ s.close();
+ assertNotNull(h.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ Home reloadedHome = (Home) s.get(Home.class, h.getId());
+ assertEquals(h.getId(), reloadedHome.getId());
+ s.delete(reloadedHome);
+ tx.commit();
+ s.close();
+ }
+
+ public void testParameterizedAuto() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Home h = new Home();
+ s.persist(h);
+ tx.commit();
+ s.close();
+ assertNotNull(h.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ Home reloadedHome = (Home) s.get(Home.class, h.getId());
+ assertEquals(h.getId(), reloadedHome.getId());
+ s.delete(reloadedHome);
+ tx.commit();
+ s.close();
+ }
+
+ public void testIdInEmbeddableSuperclass() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ FirTree chrismasTree = new FirTree();
+ s.persist(chrismasTree);
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ chrismasTree = (FirTree) s.get(FirTree.class, chrismasTree.getId());
+ assertNotNull(chrismasTree);
+ s.delete(chrismasTree);
+ tx.commit();
+ s.close();
+ }
+
+ public void testIdClass() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Footballer fb = new Footballer("David", "Beckam", "Arsenal");
+ GoalKeeper keeper = new GoalKeeper("Fabien", "Bartez", "OM");
+ s.persist(fb);
+ s.persist(keeper);
+ tx.commit();
+ s.clear();
+
+ // lookup by id
+ tx = s.beginTransaction();
+ FootballerPk fpk = new FootballerPk("David", "Beckam");
+ fb = (Footballer) s.get(Footballer.class, fpk);
+ FootballerPk fpk2 = new FootballerPk("Fabien", "Bartez");
+ keeper = (GoalKeeper) s.get(GoalKeeper.class, fpk2);
+ assertNotNull(fb);
+ assertNotNull(keeper);
+ assertEquals("Beckam", fb.getLastname());
+ assertEquals("Arsenal", fb.getClub());
+ assertEquals(1, s.createQuery(
+ "from Footballer f where f.firstname = 'David'").list().size());
+ tx.commit();
+
+ // reattach by merge
+ tx = s.beginTransaction();
+ fb.setClub("Bimbo FC");
+ s.merge(fb);
+ tx.commit();
+
+ // reattach by saveOrUpdate
+ tx = s.beginTransaction();
+ fb.setClub("Bimbo FC SA");
+ s.saveOrUpdate(fb);
+ tx.commit();
+
+ // clean up
+ s.clear();
+ tx = s.beginTransaction();
+ fpk = new FootballerPk("David", "Beckam");
+ fb = (Footballer) s.get(Footballer.class, fpk);
+ assertEquals("Bimbo FC SA", fb.getClub());
+ s.delete(fb);
+ s.delete(keeper);
+ tx.commit();
+ s.close();
+ }
+
+ public void testColumnDefinition() {
+ Column idCol = (Column) getCfg().getClassMapping(Ball.class.getName())
+ .getIdentifierProperty().getValue().getColumnIterator().next();
+ assertEquals("ball_id", idCol.getName());
+ }
+
+ public void testLowAllocationSize() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ int size = 4;
+ BreakDance[] bds = new BreakDance[size];
+ for (int i = 0; i < size; i++) {
+ bds[i] = new BreakDance();
+ s.persist(bds[i]);
+ }
+ s.flush();
+ for (int i = 0; i < size; i++) {
+ assertEquals(i + 1, bds[i].id.intValue());
+ }
+ tx.rollback();
+ s.close();
+ }
+
+
+
+ @Override
+ protected boolean runForCurrentDialect() {
+ return super.runForCurrentDialect() && getDialect().supportsSequences();
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getMappings()
+ */
+ protected Class[] getMappings() {
+ return new Class[] { Ball.class, Shoe.class, Store.class,
+ Department.class, Dog.class, Computer.class, Home.class,
+ Phone.class, Tree.class, FirTree.class, Footballer.class,
+ SoundSystem.class, Furniture.class, GoalKeeper.class,
+ BreakDance.class, Monkey.class};
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getAnnotatedPackages()
+ */
+ protected String[] getAnnotatedPackages() {
+ return new String[] { "org.hibernate.test.annotations",
+ "org.hibernate.test.annotations.id" };
+ }
+
+ @Override
+ protected String[] getXmlFiles() {
+ return new String[] { "org/hibernate/test/annotations/orm.xml" };
+ }
+
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,64 @@
+//$Id: JoinColumnOverrideTest.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.entities.Bunny;
+import org.hibernate.test.annotations.id.entities.PointyTooth;
+import org.hibernate.test.annotations.id.entities.TwinkleToes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tests for JIRA issue ANN-748.
+ *
+ * @author Hardy Ferentschik
+ */
+@SuppressWarnings("unchecked")
+public class JoinColumnOverrideTest extends TestCase {
+
+ private Logger log = LoggerFactory.getLogger(JoinColumnOverrideTest.class);
+
+ public JoinColumnOverrideTest(String x) {
+ super(x);
+ }
+
+ public void testBlownPrecision() throws Exception {
+
+ try {
+ AnnotationConfiguration config = new AnnotationConfiguration();
+ config.addAnnotatedClass(Bunny.class);
+ config.addAnnotatedClass(PointyTooth.class);
+ config.addAnnotatedClass(TwinkleToes.class);
+ config.buildSessionFactory();
+ String[] schema = config
+ .generateSchemaCreationScript(new SQLServerDialect());
+ for (String s : schema) {
+ log.debug(s);
+ }
+ String expectedSqlPointyTooth = "create table PointyTooth (id numeric(128,0) not null, " +
+ "bunny_id numeric(128,0) null, primary key (id))";
+ assertEquals("Wrong SQL", expectedSqlPointyTooth, schema[1]);
+
+ String expectedSqlTwinkleToes = "create table TwinkleToes (id numeric(128,0) not null, " +
+ "bunny_id numeric(128,0) null, primary key (id))";
+ assertEquals("Wrong SQL", expectedSqlTwinkleToes, schema[2]);
+ } catch (Exception e) {
+ StringWriter writer = new StringWriter();
+ e.printStackTrace(new PrintWriter(writer));
+ log.debug(writer.toString());
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getMappings()
+ */
+ protected Class[] getMappings() {
+ return new Class[] {};
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,34 @@
+package org.hibernate.test.annotations.id.sequences;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.UUID;
+
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.id.IdentifierGenerator;
+
+/**
+ * Unlike Hibernate's UUID generator. This avoids
+ * meaningless synchronization and has less
+ * than a chance of an asteroid hitting you on the head
+ * even after trillions of rows are inserted. I know
+ * this to be true because it says so in Wikipedia(haha).
+ * http://en.wikipedia.org/wiki/UUID#Random_UUID_probability_of_duplicates
+ *
+ */
+public class UUIDGenerator implements IdentifierGenerator {
+
+ public Serializable generate(SessionImplementor arg0, Object arg1) throws HibernateException {
+ UUID uuid = UUID.randomUUID();
+ String sud = uuid.toString();
+ System.out.println("uuid="+uuid);
+ sud = sud.replaceAll("-", "");
+
+ BigInteger integer = new BigInteger(sud,16);
+
+ System.out.println("bi ="+integer.toString() );
+ return integer;
+ }
+
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Ball.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Ball.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Ball.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,35 @@
+//$Id: Ball.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.TableGenerator;
+
+/**
+ * Sample of table generator
+ *
+ * @author Emmanuel Bernard
+ */
+@TableGenerator(name = "EMP_GEN", table = "GENERATOR_TABLE", pkColumnName = "pkey",
+ valueColumnName = "hi", pkColumnValue = "Ball", allocationSize = 10)
+@Entity
+@SuppressWarnings("serial")
+public class Ball implements Serializable {
+ private Integer id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.TABLE, generator = "EMP_GEN")
+ @Column(name = "ball_id")
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,27 @@
+//$Id: BreakDance.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.TableGenerator;
+import javax.persistence.GenerationType;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class BreakDance {
+ @Id
+ @GeneratedValue(generator = "memencoIdGen", strategy = GenerationType.TABLE)
+ @TableGenerator(
+ name = "memencoIdGen",
+ table = "hi_id_key",
+ pkColumnName = "id_key",
+ valueColumnName = "next_hi",
+ pkColumnValue = "issue",
+ allocationSize = 1
+ )
+ public Integer id;
+ public String name;
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,46 @@
+//$Id: Bunny.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * Blown precision on related entity when @JoinColumn is used.
+ *
+ * @see ANN-748
+ * @author Andrew C. Oliver andyspam(a)osintegrators.com
+ */
+@Entity
+@SuppressWarnings("serial")
+public class Bunny implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @Column(name = "id", precision = 128, scale = 0)
+ private BigInteger id;
+
+ @OneToMany(mappedBy = "bunny", cascade = { CascadeType.PERSIST })
+ Set<PointyTooth> teeth;
+
+ @OneToMany(mappedBy = "bunny", cascade = { CascadeType.PERSIST })
+ Set<TwinkleToes> toes;
+
+ public void setTeeth(Set<PointyTooth> teeth) {
+ this.teeth = teeth;
+ }
+
+ public BigInteger getId() {
+ return id;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Computer.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Computer.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Computer.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,34 @@
+//$Id: Computer.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity()
+public class Computer {
+ private Long id;
+ private String serialNumber;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.TABLE)
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getSerialNumber() {
+ return serialNumber;
+ }
+
+ public void setSerialNumber(String serialNumber) {
+ this.serialNumber = serialNumber;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Department.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Department.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Department.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,33 @@
+//$Id: Department.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * Sample of method generator
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+@SuppressWarnings("serial")
+public class Department implements Serializable {
+ private Long id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_DEPT")
+ @javax.persistence.SequenceGenerator(
+ name = "SEQ_DEPT",
+ sequenceName = "my_sequence"
+ )
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long long1) {
+ id = long1;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Dog.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Dog.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Dog.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,42 @@
+//$Id: Dog.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+/**
+ * Share the generator table decribed by the GEN_TABLE GeneratedIdTable
+ * using the Dog key as discriminator
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name = "tbl_dog")
+@TableGenerator(name = "DogGen", table = "GENERATOR_TABLE", pkColumnName = "pkey",
+ valueColumnName = "hi", pkColumnValue = "Dog", allocationSize = 10)
+public class Dog {
+ private Integer id;
+ private String name;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.TABLE, generator = "DogGen")
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FirTree.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FirTree.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FirTree.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,11 @@
+//$Id: FirTree.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class FirTree extends Tree {
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Footballer.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Footballer.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Footballer.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,73 @@
+//$Id: Footballer.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+(a)IdClass(FootballerPk.class)
+@DiscriminatorColumn(name = "bibi")
+public class Footballer {
+ private String firstname;
+ private String lastname;
+ private String club;
+
+ public Footballer() {
+ }
+
+ public Footballer(String firstname, String lastname, String club) {
+ this.firstname = firstname;
+ this.lastname = lastname;
+ this.club = club;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) return true;
+ if ( !( o instanceof Footballer ) ) return false;
+
+ final Footballer footballer = (Footballer) o;
+
+ if ( !firstname.equals( footballer.firstname ) ) return false;
+ if ( !lastname.equals( footballer.lastname ) ) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = firstname.hashCode();
+ result = 29 * result + lastname.hashCode();
+ return result;
+ }
+
+ @Id
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ @Id
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public String getClub() {
+ return club;
+ }
+
+ public void setClub(String club) {
+ this.club = club;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,62 @@
+//$Id: FootballerPk.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Embeddable
+@SuppressWarnings("serial")
+public class FootballerPk implements Serializable {
+ private String firstname;
+ private String lastname;
+
+ @Column(name = "fb_fname")
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public FootballerPk() {
+ }
+
+ public FootballerPk(String firstname, String lastname) {
+ this.firstname = firstname;
+ this.lastname = lastname;
+
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) return true;
+ if ( !( o instanceof FootballerPk ) ) return false;
+
+ final FootballerPk footballerPk = (FootballerPk) o;
+
+ if ( !firstname.equals( footballerPk.firstname ) ) return false;
+ if ( !lastname.equals( footballerPk.lastname ) ) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = firstname.hashCode();
+ result = 29 * result + lastname.hashCode();
+ return result;
+ }
+
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Furniture.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Furniture.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Furniture.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,33 @@
+//$Id: Furniture.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.annotations.GenericGenerator;
+import org.hibernate.annotations.Parameter;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Furniture {
+ private Integer id;
+
+ @Id
+ @GeneratedValue(generator = "hibseq")
+ @GenericGenerator(name = "hibseq", strategy = "seqhilo",
+ parameters = {
+ @Parameter(name = "max_lo", value = "5"),
+ @Parameter(name = "sequence", value = "heybabyhey")
+ }
+ )
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,17 @@
+//$Id: GoalKeeper.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class GoalKeeper extends Footballer {
+ public GoalKeeper() {
+ }
+
+ public GoalKeeper(String firstname, String lastname, String club) {
+ super( firstname, lastname, club );
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Home.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Home.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Home.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,26 @@
+//$Id: Home.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * Default sequence generation usage
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Home {
+ private Long id;
+
+ @Id
+ @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Location.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Location.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Location.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,35 @@
+//$Id: Location.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@SuppressWarnings("serial")
+public class Location implements Serializable {
+ public double longitude;
+ public double latitude;
+
+ public boolean equals(Object o) {
+ if ( this == o ) return true;
+ if ( o == null || getClass() != o.getClass() ) return false;
+
+ final Location location = (Location) o;
+
+ if ( Double.compare( location.latitude, latitude ) != 0 ) return false;
+ if ( Double.compare( location.longitude, longitude ) != 0 ) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ long temp;
+ temp = longitude != +0.0d ? Double.doubleToLongBits( longitude ) : 0L;
+ result = (int) ( temp ^ ( temp >>> 32 ) );
+ temp = latitude != +0.0d ? Double.doubleToLongBits( latitude ) : 0L;
+ result = 29 * result + (int) ( temp ^ ( temp >>> 32 ) );
+ return result;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,18 @@
+//$Id: MilitaryBuilding.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.MappedSuperclass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+(a)IdClass(Location.class)
+public class MilitaryBuilding {
+ @Id
+ public double longitude;
+ @Id
+ public double latitude;
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Monkey.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Monkey.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Monkey.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,24 @@
+//$
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Paul Cowan
+ */
+@Entity
+public class Monkey {
+ private String id;
+
+ @Id
+ @GeneratedValue(generator = "system-uuid-2")
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Phone.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Phone.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Phone.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,29 @@
+//$Id: Phone.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity()
+public class Phone {
+ private Integer id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Phone_Gen")
+ @javax.persistence.SequenceGenerator(
+ name = "Phone_Gen",
+ sequenceName = "phone_seq"
+ )
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Planet.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Planet.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Planet.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,6 @@
+// $Id: Planet.java 14785 2008-06-19 10:44:33Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+public enum Planet {
+ MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO;
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,85 @@
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+
+
+/**
+ * Test entity for enum type as id.
+ *
+ * @author Hardy Ferentschik
+ * @see ANN-744
+ */
+@Entity
+public class PlanetCheatSheet {
+
+ @Id
+ @Enumerated(EnumType.STRING)
+ @Column(name = "planet")
+ private Planet planet;
+
+ private double mass;
+
+ private double radius;
+
+ private long numberOfInhabitants;
+
+ public Planet getPlanet() {
+ return planet;
+ }
+
+ public void setPlanet(Planet planet) {
+ this.planet = planet;
+ }
+
+ public double getMass() {
+ return mass;
+ }
+
+ public void setMass(double mass) {
+ this.mass = mass;
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+
+ public void setRadius(double radius) {
+ this.radius = radius;
+ }
+
+ public long getNumberOfInhabitants() {
+ return numberOfInhabitants;
+ }
+
+ public void setNumberOfInhabitants(long numberOfInhabitants) {
+ this.numberOfInhabitants = numberOfInhabitants;
+ }
+
+ /**
+ * Constructs a <code>String</code> with all attributes
+ * in name = value format.
+ *
+ * @return a <code>String</code> representation
+ * of this object.
+ */
+ public String toString()
+ {
+ final String TAB = " ";
+
+ String retValue = "";
+
+ retValue = "PlanetCheatSheet ( "
+ + super.toString() + TAB
+ + "planet = " + this.planet + TAB
+ + "mass = " + this.mass + TAB
+ + "radius = " + this.radius + TAB
+ + "numberOfInhabitants = " + this.numberOfInhabitants + TAB
+ + " )";
+
+ return retValue;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,44 @@
+//$Id: PointyTooth.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * Blown precision on related entity when @JoinColumn is used.
+ * Does not cause an issue on HyperSonic, but replicates nicely on PGSQL.
+ *
+ * @see ANN-748
+ * @author Andrew C. Oliver andyspam(a)osintegrators.com
+ */
+@Entity
+@SuppressWarnings("serial")
+public class PointyTooth implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @Column(name = "id", precision = 128, scale = 0)
+ private BigInteger id;
+
+ @ManyToOne
+ @JoinColumn(name = "bunny_id")
+ Bunny bunny;
+
+ public void setBunny(Bunny bunny) {
+ this.bunny = bunny;
+ }
+
+ public BigInteger getId() {
+ return id;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Shoe.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Shoe.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Shoe.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,29 @@
+//$Id: Shoe.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * sample of Sequance generator
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+@SuppressWarnings("serial")
+public class Shoe implements Serializable {
+ private Long id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN")
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long long1) {
+ id = long1;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,42 @@
+//$Id: SoundSystem.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class SoundSystem {
+ private String id;
+ private String brand;
+ private String model;
+
+ @Id
+ @GeneratedValue(generator = "system-uuid")
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Store.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Store.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Store.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,33 @@
+//$Id: Store.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * Sample of class generator
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+(a)javax.persistence.SequenceGenerator(
+ name = "SEQ_STORE",
+ sequenceName = "my_sequence"
+)
+@SuppressWarnings("serial")
+public class Store implements Serializable {
+ private Long id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long long1) {
+ id = long1;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tower.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tower.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tower.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,14 @@
+//$Id: Tower.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@AttributeOverride(name = "longitude", column = @Column(name = "fld_longitude"))
+public class Tower extends MilitaryBuilding {
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tree.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tree.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tree.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,24 @@
+//$Id: Tree.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+public class Tree {
+ private Integer id;
+
+ @Id
+ @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,42 @@
+//$Id: TwinkleToes.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * Blown precision on related entity when @JoinColumn is used.
+ * Does not cause an issue on HyperSonic, but replicates nicely on PGSQL.
+ *
+ * @see ANN-748
+ * @author Andrew C. Oliver andyspam(a)osintegrators.com
+ */
+@Entity
+@SuppressWarnings("serial")
+public class TwinkleToes implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @Column(name = "id", precision = 128, scale = 0)
+ private BigInteger id;
+
+ @ManyToOne
+ Bunny bunny;
+
+ public void setBunny(Bunny bunny) {
+ this.bunny = bunny;
+ }
+
+ public BigInteger getId() {
+ return id;
+ }
+}
Added: annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/package-info.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/package-info.java (rev 0)
+++ annotations/branches/v3_4_0_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/package-info.java 2009-10-14 05:15:33 UTC (rev 17735)
@@ -0,0 +1,11 @@
+//$Id: package-info.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
+/**
+ * Test package for metatata facilities
+ * It contains an example of package level metadata
+ */
+(a)org.hibernate.annotations.GenericGenerator(name = "system-uuid", strategy = "uuid")
+(a)org.hibernate.annotations.GenericGenerators(
+ @org.hibernate.annotations.GenericGenerator(name = "system-uuid-2", strategy = "uuid")
+)
+package org.hibernate.test.annotations.id.sequences;
+
16 years, 2 months
Hibernate SVN: r17734 - in core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id: entities and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-10-14 00:18:35 -0400 (Wed, 14 Oct 2009)
New Revision: 17734
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/EnumIdTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdClassTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Ball.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Bunny.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Computer.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Department.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Dog.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/FirTree.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Footballer.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Furniture.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Home.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Location.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Monkey.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Phone.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Planet.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Shoe.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Store.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Tower.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Tree.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/package-info.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/IdTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Department.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Phone.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Shoe.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Store.java
Log:
HHH-4397 Split test involving database specific features (like sequence / identity)
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/IdTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/IdTest.java 2009-10-13 20:56:34 UTC (rev 17733)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/IdTest.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -3,9 +3,7 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.dialect.HSQLDialect;
import org.hibernate.mapping.Column;
-import org.hibernate.test.annotations.RequiresDialect;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.test.annotations.id.entities.Ball;
import org.hibernate.test.annotations.id.entities.BreakDance;
@@ -29,9 +27,7 @@
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
-(a)RequiresDialect(HSQLDialect.class)
public class IdTest extends TestCase {
- // FIXME split Sequence and Id tests to explicit the run failure on Oracle etc
public void testGenericGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Department.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Department.java 2009-10-13 20:56:34 UTC (rev 17733)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Department.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -18,11 +18,7 @@
private Long id;
@Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_DEPT")
- @javax.persistence.SequenceGenerator(
- name = "SEQ_DEPT",
- sequenceName = "my_sequence"
- )
+ @GeneratedValue
public Long getId() {
return id;
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Phone.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Phone.java 2009-10-13 20:56:34 UTC (rev 17733)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Phone.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -3,7 +3,6 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
@@ -14,11 +13,7 @@
private Integer id;
@Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Phone_Gen")
- @javax.persistence.SequenceGenerator(
- name = "Phone_Gen",
- sequenceName = "phone_seq"
- )
+ @GeneratedValue
public Integer getId() {
return id;
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Shoe.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Shoe.java 2009-10-13 20:56:34 UTC (rev 17733)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Shoe.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -18,7 +18,7 @@
private Long id;
@Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN")
+ @GeneratedValue
public Long getId() {
return id;
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Store.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Store.java 2009-10-13 20:56:34 UTC (rev 17733)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/entities/Store.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -13,16 +13,12 @@
* @author Emmanuel Bernard
*/
@Entity
-(a)javax.persistence.SequenceGenerator(
- name = "SEQ_STORE",
- sequenceName = "my_sequence"
-)
@SuppressWarnings("serial")
public class Store implements Serializable {
private Long id;
@Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
+ @GeneratedValue
public Long getId() {
return id;
}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/EnumIdTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/EnumIdTest.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/EnumIdTest.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,62 @@
+//$Id: EnumIdTest.java 14785 2008-06-19 10:44:33Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.entities.Planet;
+import org.hibernate.test.annotations.id.entities.PlanetCheatSheet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tests for enum type as id.
+ *
+ * @author Hardy Ferentschik
+ * @see ANN-744
+ */
+@SuppressWarnings("unchecked")
+public class EnumIdTest extends TestCase {
+
+ private Logger log = LoggerFactory.getLogger(EnumIdTest.class);
+
+ public EnumIdTest(String x) {
+ super(x);
+ }
+
+ public void testEnumAsId() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ PlanetCheatSheet mercury = new PlanetCheatSheet();
+ mercury.setPlanet(Planet.MERCURY);
+ mercury.setMass(3.303e+23);
+ mercury.setRadius(2.4397e6);
+ mercury.setNumberOfInhabitants(0);
+ s.persist(mercury);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ PlanetCheatSheet mercuryFromDb = (PlanetCheatSheet) s.get(PlanetCheatSheet.class, mercury.getPlanet());
+ assertNotNull(mercuryFromDb);
+ log.debug(mercuryFromDb.toString());
+ s.delete(mercuryFromDb);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ mercury = (PlanetCheatSheet) s.get(PlanetCheatSheet.class, Planet.MERCURY);
+ assertNull(mercury);
+ tx.commit();
+ s.close();
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getMappings()
+ */
+ protected Class[] getMappings() {
+ return new Class[] { PlanetCheatSheet.class };
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdClassTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdClassTest.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdClassTest.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,38 @@
+//$Id: IdClassTest.java 14784 2008-06-19 10:42:20Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.entities.Location;
+import org.hibernate.test.annotations.id.entities.Tower;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@SuppressWarnings("unchecked")
+public class IdClassTest extends TestCase {
+
+ public void testIdClassInSuperclass() throws Exception {
+ Tower tower = new Tower();
+ tower.latitude = 10.3;
+ tower.longitude = 45.4;
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( tower );
+ s.flush();
+ s.clear();
+ Location loc = new Location();
+ loc.latitude = tower.latitude;
+ loc.longitude = tower.longitude;
+ assertNotNull( s.get( Tower.class, loc ) );
+ tx.rollback();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[]{
+ Tower.class
+ };
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,308 @@
+//$Id: IdTest.java 15025 2008-08-11 09:14:39Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.mapping.Column;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.sequences.entities.Ball;
+import org.hibernate.test.annotations.id.sequences.entities.BreakDance;
+import org.hibernate.test.annotations.id.sequences.entities.Computer;
+import org.hibernate.test.annotations.id.sequences.entities.Department;
+import org.hibernate.test.annotations.id.sequences.entities.Dog;
+import org.hibernate.test.annotations.id.sequences.entities.FirTree;
+import org.hibernate.test.annotations.id.sequences.entities.Footballer;
+import org.hibernate.test.annotations.id.sequences.entities.FootballerPk;
+import org.hibernate.test.annotations.id.sequences.entities.Furniture;
+import org.hibernate.test.annotations.id.sequences.entities.GoalKeeper;
+import org.hibernate.test.annotations.id.sequences.entities.Home;
+import org.hibernate.test.annotations.id.sequences.entities.Monkey;
+import org.hibernate.test.annotations.id.sequences.entities.Phone;
+import org.hibernate.test.annotations.id.sequences.entities.Shoe;
+import org.hibernate.test.annotations.id.sequences.entities.SoundSystem;
+import org.hibernate.test.annotations.id.sequences.entities.Store;
+import org.hibernate.test.annotations.id.sequences.entities.Tree;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@SuppressWarnings("unchecked")
+public class IdTest extends TestCase {
+ public void testGenericGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ SoundSystem system = new SoundSystem();
+ system.setBrand("Genelec");
+ system.setModel("T234");
+ Furniture fur = new Furniture();
+ s.persist(system);
+ s.persist(fur);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ system = (SoundSystem) s.get(SoundSystem.class, system.getId());
+ fur = (Furniture) s.get(Furniture.class, fur.getId());
+ assertNotNull(system);
+ assertNotNull(fur);
+ s.delete(system);
+ s.delete(fur);
+ tx.commit();
+ s.close();
+
+ }
+
+ /*
+ * Ensures that GenericGenerator annotations wrapped inside a
+ * GenericGenerators holder are bound correctly
+ */
+ public void testGenericGenerators() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Monkey monkey = new Monkey();
+ s.persist(monkey);
+ s.flush();
+ assertNotNull(monkey.getId());
+ tx.rollback();
+ s.close();
+ }
+
+ public void testTableGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+
+ Ball b = new Ball();
+ Dog d = new Dog();
+ Computer c = new Computer();
+ s.persist(b);
+ s.persist(d);
+ s.persist(c);
+ tx.commit();
+ s.close();
+ assertEquals("table id not generated", new Integer(1), b.getId());
+ assertEquals("generator should not be shared", new Integer(1), d
+ .getId());
+ assertEquals("default value should work", new Long(1), c.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete(s.get(Ball.class, new Integer(1)));
+ s.delete(s.get(Dog.class, new Integer(1)));
+ s.delete(s.get(Computer.class, new Long(1)));
+ tx.commit();
+ s.close();
+ }
+
+ public void testSequenceGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Shoe b = new Shoe();
+ s.persist(b);
+ tx.commit();
+ s.close();
+ assertNotNull(b.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete(s.get(Shoe.class, b.getId()));
+ tx.commit();
+ s.close();
+ }
+
+ public void testClassLevelGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Store b = new Store();
+ s.persist(b);
+ tx.commit();
+ s.close();
+ assertNotNull(b.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete(s.get(Store.class, b.getId()));
+ tx.commit();
+ s.close();
+ }
+
+ public void testMethodLevelGenerator() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Department b = new Department();
+ s.persist(b);
+ tx.commit();
+ s.close();
+ assertNotNull(b.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ s.delete(s.get(Department.class, b.getId()));
+ tx.commit();
+ s.close();
+ }
+
+ public void testDefaultSequence() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Home h = new Home();
+ s.persist(h);
+ tx.commit();
+ s.close();
+ assertNotNull(h.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ Home reloadedHome = (Home) s.get(Home.class, h.getId());
+ assertEquals(h.getId(), reloadedHome.getId());
+ s.delete(reloadedHome);
+ tx.commit();
+ s.close();
+ }
+
+ public void testParameterizedAuto() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Home h = new Home();
+ s.persist(h);
+ tx.commit();
+ s.close();
+ assertNotNull(h.getId());
+
+ s = openSession();
+ tx = s.beginTransaction();
+ Home reloadedHome = (Home) s.get(Home.class, h.getId());
+ assertEquals(h.getId(), reloadedHome.getId());
+ s.delete(reloadedHome);
+ tx.commit();
+ s.close();
+ }
+
+ public void testIdInEmbeddableSuperclass() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ FirTree chrismasTree = new FirTree();
+ s.persist(chrismasTree);
+ tx.commit();
+ s.clear();
+ tx = s.beginTransaction();
+ chrismasTree = (FirTree) s.get(FirTree.class, chrismasTree.getId());
+ assertNotNull(chrismasTree);
+ s.delete(chrismasTree);
+ tx.commit();
+ s.close();
+ }
+
+ public void testIdClass() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ Footballer fb = new Footballer("David", "Beckam", "Arsenal");
+ GoalKeeper keeper = new GoalKeeper("Fabien", "Bartez", "OM");
+ s.persist(fb);
+ s.persist(keeper);
+ tx.commit();
+ s.clear();
+
+ // lookup by id
+ tx = s.beginTransaction();
+ FootballerPk fpk = new FootballerPk("David", "Beckam");
+ fb = (Footballer) s.get(Footballer.class, fpk);
+ FootballerPk fpk2 = new FootballerPk("Fabien", "Bartez");
+ keeper = (GoalKeeper) s.get(GoalKeeper.class, fpk2);
+ assertNotNull(fb);
+ assertNotNull(keeper);
+ assertEquals("Beckam", fb.getLastname());
+ assertEquals("Arsenal", fb.getClub());
+ assertEquals(1, s.createQuery(
+ "from Footballer f where f.firstname = 'David'").list().size());
+ tx.commit();
+
+ // reattach by merge
+ tx = s.beginTransaction();
+ fb.setClub("Bimbo FC");
+ s.merge(fb);
+ tx.commit();
+
+ // reattach by saveOrUpdate
+ tx = s.beginTransaction();
+ fb.setClub("Bimbo FC SA");
+ s.saveOrUpdate(fb);
+ tx.commit();
+
+ // clean up
+ s.clear();
+ tx = s.beginTransaction();
+ fpk = new FootballerPk("David", "Beckam");
+ fb = (Footballer) s.get(Footballer.class, fpk);
+ assertEquals("Bimbo FC SA", fb.getClub());
+ s.delete(fb);
+ s.delete(keeper);
+ tx.commit();
+ s.close();
+ }
+
+ public void testColumnDefinition() {
+ Column idCol = (Column) getCfg().getClassMapping(Ball.class.getName())
+ .getIdentifierProperty().getValue().getColumnIterator().next();
+ assertEquals("ball_id", idCol.getName());
+ }
+
+ public void testLowAllocationSize() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ int size = 4;
+ BreakDance[] bds = new BreakDance[size];
+ for (int i = 0; i < size; i++) {
+ bds[i] = new BreakDance();
+ s.persist(bds[i]);
+ }
+ s.flush();
+ for (int i = 0; i < size; i++) {
+ assertEquals(i + 1, bds[i].id.intValue());
+ }
+ tx.rollback();
+ s.close();
+ }
+
+
+
+ @Override
+ protected boolean runForCurrentDialect() {
+ return super.runForCurrentDialect() && getDialect().supportsSequences();
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getMappings()
+ */
+ protected Class[] getMappings() {
+ return new Class[] { Ball.class, Shoe.class, Store.class,
+ Department.class, Dog.class, Computer.class, Home.class,
+ Phone.class, Tree.class, FirTree.class, Footballer.class,
+ SoundSystem.class, Furniture.class, GoalKeeper.class,
+ BreakDance.class, Monkey.class};
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getAnnotatedPackages()
+ */
+ protected String[] getAnnotatedPackages() {
+ return new String[] { "org.hibernate.test.annotations",
+ "org.hibernate.test.annotations.id" };
+ }
+
+ @Override
+ protected String[] getXmlFiles() {
+ return new String[] { "org/hibernate/test/annotations/orm.xml" };
+ }
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,64 @@
+//$Id: JoinColumnOverrideTest.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.entities.Bunny;
+import org.hibernate.test.annotations.id.entities.PointyTooth;
+import org.hibernate.test.annotations.id.entities.TwinkleToes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tests for JIRA issue ANN-748.
+ *
+ * @author Hardy Ferentschik
+ */
+@SuppressWarnings("unchecked")
+public class JoinColumnOverrideTest extends TestCase {
+
+ private Logger log = LoggerFactory.getLogger(JoinColumnOverrideTest.class);
+
+ public JoinColumnOverrideTest(String x) {
+ super(x);
+ }
+
+ public void testBlownPrecision() throws Exception {
+
+ try {
+ AnnotationConfiguration config = new AnnotationConfiguration();
+ config.addAnnotatedClass(Bunny.class);
+ config.addAnnotatedClass(PointyTooth.class);
+ config.addAnnotatedClass(TwinkleToes.class);
+ config.buildSessionFactory();
+ String[] schema = config
+ .generateSchemaCreationScript(new SQLServerDialect());
+ for (String s : schema) {
+ log.debug(s);
+ }
+ String expectedSqlPointyTooth = "create table PointyTooth (id numeric(128,0) not null, " +
+ "bunny_id numeric(128,0) null, primary key (id))";
+ assertEquals("Wrong SQL", expectedSqlPointyTooth, schema[1]);
+
+ String expectedSqlTwinkleToes = "create table TwinkleToes (id numeric(128,0) not null, " +
+ "bunny_id numeric(128,0) null, primary key (id))";
+ assertEquals("Wrong SQL", expectedSqlTwinkleToes, schema[2]);
+ } catch (Exception e) {
+ StringWriter writer = new StringWriter();
+ e.printStackTrace(new PrintWriter(writer));
+ log.debug(writer.toString());
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getMappings()
+ */
+ protected Class[] getMappings() {
+ return new Class[] {};
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,34 @@
+package org.hibernate.test.annotations.id.sequences;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.UUID;
+
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.id.IdentifierGenerator;
+
+/**
+ * Unlike Hibernate's UUID generator. This avoids
+ * meaningless synchronization and has less
+ * than a chance of an asteroid hitting you on the head
+ * even after trillions of rows are inserted. I know
+ * this to be true because it says so in Wikipedia(haha).
+ * http://en.wikipedia.org/wiki/UUID#Random_UUID_probability_of_duplicates
+ *
+ */
+public class UUIDGenerator implements IdentifierGenerator {
+
+ public Serializable generate(SessionImplementor arg0, Object arg1) throws HibernateException {
+ UUID uuid = UUID.randomUUID();
+ String sud = uuid.toString();
+ System.out.println("uuid="+uuid);
+ sud = sud.replaceAll("-", "");
+
+ BigInteger integer = new BigInteger(sud,16);
+
+ System.out.println("bi ="+integer.toString() );
+ return integer;
+ }
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Ball.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Ball.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Ball.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,35 @@
+//$Id: Ball.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.TableGenerator;
+
+/**
+ * Sample of table generator
+ *
+ * @author Emmanuel Bernard
+ */
+@TableGenerator(name = "EMP_GEN", table = "GENERATOR_TABLE", pkColumnName = "pkey",
+ valueColumnName = "hi", pkColumnValue = "Ball", allocationSize = 10)
+@Entity
+@SuppressWarnings("serial")
+public class Ball implements Serializable {
+ private Integer id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.TABLE, generator = "EMP_GEN")
+ @Column(name = "ball_id")
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,27 @@
+//$Id: BreakDance.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.TableGenerator;
+import javax.persistence.GenerationType;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class BreakDance {
+ @Id
+ @GeneratedValue(generator = "memencoIdGen", strategy = GenerationType.TABLE)
+ @TableGenerator(
+ name = "memencoIdGen",
+ table = "hi_id_key",
+ pkColumnName = "id_key",
+ valueColumnName = "next_hi",
+ pkColumnValue = "issue",
+ allocationSize = 1
+ )
+ public Integer id;
+ public String name;
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Bunny.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Bunny.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Bunny.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,46 @@
+//$Id: Bunny.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * Blown precision on related entity when @JoinColumn is used.
+ *
+ * @see ANN-748
+ * @author Andrew C. Oliver andyspam(a)osintegrators.com
+ */
+@Entity
+@SuppressWarnings("serial")
+public class Bunny implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @Column(name = "id", precision = 128, scale = 0)
+ private BigInteger id;
+
+ @OneToMany(mappedBy = "bunny", cascade = { CascadeType.PERSIST })
+ Set<PointyTooth> teeth;
+
+ @OneToMany(mappedBy = "bunny", cascade = { CascadeType.PERSIST })
+ Set<TwinkleToes> toes;
+
+ public void setTeeth(Set<PointyTooth> teeth) {
+ this.teeth = teeth;
+ }
+
+ public BigInteger getId() {
+ return id;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Computer.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Computer.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Computer.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,34 @@
+//$Id: Computer.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity()
+public class Computer {
+ private Long id;
+ private String serialNumber;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.TABLE)
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getSerialNumber() {
+ return serialNumber;
+ }
+
+ public void setSerialNumber(String serialNumber) {
+ this.serialNumber = serialNumber;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Department.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Department.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Department.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,33 @@
+//$Id: Department.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * Sample of method generator
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+@SuppressWarnings("serial")
+public class Department implements Serializable {
+ private Long id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_DEPT")
+ @javax.persistence.SequenceGenerator(
+ name = "SEQ_DEPT",
+ sequenceName = "my_sequence"
+ )
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long long1) {
+ id = long1;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Dog.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Dog.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Dog.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,42 @@
+//$Id: Dog.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+/**
+ * Share the generator table decribed by the GEN_TABLE GeneratedIdTable
+ * using the Dog key as discriminator
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name = "tbl_dog")
+@TableGenerator(name = "DogGen", table = "GENERATOR_TABLE", pkColumnName = "pkey",
+ valueColumnName = "hi", pkColumnValue = "Dog", allocationSize = 10)
+public class Dog {
+ private Integer id;
+ private String name;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.TABLE, generator = "DogGen")
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/FirTree.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/FirTree.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/FirTree.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,11 @@
+//$Id: FirTree.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class FirTree extends Tree {
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Footballer.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Footballer.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Footballer.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,73 @@
+//$Id: Footballer.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+(a)IdClass(FootballerPk.class)
+@DiscriminatorColumn(name = "bibi")
+public class Footballer {
+ private String firstname;
+ private String lastname;
+ private String club;
+
+ public Footballer() {
+ }
+
+ public Footballer(String firstname, String lastname, String club) {
+ this.firstname = firstname;
+ this.lastname = lastname;
+ this.club = club;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) return true;
+ if ( !( o instanceof Footballer ) ) return false;
+
+ final Footballer footballer = (Footballer) o;
+
+ if ( !firstname.equals( footballer.firstname ) ) return false;
+ if ( !lastname.equals( footballer.lastname ) ) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = firstname.hashCode();
+ result = 29 * result + lastname.hashCode();
+ return result;
+ }
+
+ @Id
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ @Id
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public String getClub() {
+ return club;
+ }
+
+ public void setClub(String club) {
+ this.club = club;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,62 @@
+//$Id: FootballerPk.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Embeddable
+@SuppressWarnings("serial")
+public class FootballerPk implements Serializable {
+ private String firstname;
+ private String lastname;
+
+ @Column(name = "fb_fname")
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public FootballerPk() {
+ }
+
+ public FootballerPk(String firstname, String lastname) {
+ this.firstname = firstname;
+ this.lastname = lastname;
+
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) return true;
+ if ( !( o instanceof FootballerPk ) ) return false;
+
+ final FootballerPk footballerPk = (FootballerPk) o;
+
+ if ( !firstname.equals( footballerPk.firstname ) ) return false;
+ if ( !lastname.equals( footballerPk.lastname ) ) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = firstname.hashCode();
+ result = 29 * result + lastname.hashCode();
+ return result;
+ }
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Furniture.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Furniture.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Furniture.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,33 @@
+//$Id: Furniture.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.annotations.GenericGenerator;
+import org.hibernate.annotations.Parameter;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Furniture {
+ private Integer id;
+
+ @Id
+ @GeneratedValue(generator = "hibseq")
+ @GenericGenerator(name = "hibseq", strategy = "seqhilo",
+ parameters = {
+ @Parameter(name = "max_lo", value = "5"),
+ @Parameter(name = "sequence", value = "heybabyhey")
+ }
+ )
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,17 @@
+//$Id: GoalKeeper.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class GoalKeeper extends Footballer {
+ public GoalKeeper() {
+ }
+
+ public GoalKeeper(String firstname, String lastname, String club) {
+ super( firstname, lastname, club );
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Home.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Home.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Home.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,26 @@
+//$Id: Home.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * Default sequence generation usage
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Home {
+ private Long id;
+
+ @Id
+ @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Location.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Location.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Location.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,35 @@
+//$Id: Location.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@SuppressWarnings("serial")
+public class Location implements Serializable {
+ public double longitude;
+ public double latitude;
+
+ public boolean equals(Object o) {
+ if ( this == o ) return true;
+ if ( o == null || getClass() != o.getClass() ) return false;
+
+ final Location location = (Location) o;
+
+ if ( Double.compare( location.latitude, latitude ) != 0 ) return false;
+ if ( Double.compare( location.longitude, longitude ) != 0 ) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ long temp;
+ temp = longitude != +0.0d ? Double.doubleToLongBits( longitude ) : 0L;
+ result = (int) ( temp ^ ( temp >>> 32 ) );
+ temp = latitude != +0.0d ? Double.doubleToLongBits( latitude ) : 0L;
+ result = 29 * result + (int) ( temp ^ ( temp >>> 32 ) );
+ return result;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,18 @@
+//$Id: MilitaryBuilding.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.MappedSuperclass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+(a)IdClass(Location.class)
+public class MilitaryBuilding {
+ @Id
+ public double longitude;
+ @Id
+ public double latitude;
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Monkey.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Monkey.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Monkey.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,24 @@
+//$
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Paul Cowan
+ */
+@Entity
+public class Monkey {
+ private String id;
+
+ @Id
+ @GeneratedValue(generator = "system-uuid-2")
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Phone.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Phone.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Phone.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,29 @@
+//$Id: Phone.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity()
+public class Phone {
+ private Integer id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Phone_Gen")
+ @javax.persistence.SequenceGenerator(
+ name = "Phone_Gen",
+ sequenceName = "phone_seq"
+ )
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Planet.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Planet.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Planet.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,6 @@
+// $Id: Planet.java 14785 2008-06-19 10:44:33Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+public enum Planet {
+ MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO;
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,85 @@
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+
+
+/**
+ * Test entity for enum type as id.
+ *
+ * @author Hardy Ferentschik
+ * @see ANN-744
+ */
+@Entity
+public class PlanetCheatSheet {
+
+ @Id
+ @Enumerated(EnumType.STRING)
+ @Column(name = "planet")
+ private Planet planet;
+
+ private double mass;
+
+ private double radius;
+
+ private long numberOfInhabitants;
+
+ public Planet getPlanet() {
+ return planet;
+ }
+
+ public void setPlanet(Planet planet) {
+ this.planet = planet;
+ }
+
+ public double getMass() {
+ return mass;
+ }
+
+ public void setMass(double mass) {
+ this.mass = mass;
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+
+ public void setRadius(double radius) {
+ this.radius = radius;
+ }
+
+ public long getNumberOfInhabitants() {
+ return numberOfInhabitants;
+ }
+
+ public void setNumberOfInhabitants(long numberOfInhabitants) {
+ this.numberOfInhabitants = numberOfInhabitants;
+ }
+
+ /**
+ * Constructs a <code>String</code> with all attributes
+ * in name = value format.
+ *
+ * @return a <code>String</code> representation
+ * of this object.
+ */
+ public String toString()
+ {
+ final String TAB = " ";
+
+ String retValue = "";
+
+ retValue = "PlanetCheatSheet ( "
+ + super.toString() + TAB
+ + "planet = " + this.planet + TAB
+ + "mass = " + this.mass + TAB
+ + "radius = " + this.radius + TAB
+ + "numberOfInhabitants = " + this.numberOfInhabitants + TAB
+ + " )";
+
+ return retValue;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,44 @@
+//$Id: PointyTooth.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * Blown precision on related entity when @JoinColumn is used.
+ * Does not cause an issue on HyperSonic, but replicates nicely on PGSQL.
+ *
+ * @see ANN-748
+ * @author Andrew C. Oliver andyspam(a)osintegrators.com
+ */
+@Entity
+@SuppressWarnings("serial")
+public class PointyTooth implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @Column(name = "id", precision = 128, scale = 0)
+ private BigInteger id;
+
+ @ManyToOne
+ @JoinColumn(name = "bunny_id")
+ Bunny bunny;
+
+ public void setBunny(Bunny bunny) {
+ this.bunny = bunny;
+ }
+
+ public BigInteger getId() {
+ return id;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Shoe.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Shoe.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Shoe.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,29 @@
+//$Id: Shoe.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * sample of Sequance generator
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+@SuppressWarnings("serial")
+public class Shoe implements Serializable {
+ private Long id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN")
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long long1) {
+ id = long1;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,42 @@
+//$Id: SoundSystem.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class SoundSystem {
+ private String id;
+ private String brand;
+ private String model;
+
+ @Id
+ @GeneratedValue(generator = "system-uuid")
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Store.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Store.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Store.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,33 @@
+//$Id: Store.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * Sample of class generator
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+(a)javax.persistence.SequenceGenerator(
+ name = "SEQ_STORE",
+ sequenceName = "my_sequence"
+)
+@SuppressWarnings("serial")
+public class Store implements Serializable {
+ private Long id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long long1) {
+ id = long1;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Tower.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Tower.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Tower.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,14 @@
+//$Id: Tower.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@AttributeOverride(name = "longitude", column = @Column(name = "fld_longitude"))
+public class Tower extends MilitaryBuilding {
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Tree.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Tree.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/Tree.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,24 @@
+//$Id: Tree.java 14760 2008-06-11 07:33:15Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+public class Tree {
+ private Integer id;
+
+ @Id
+ @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,42 @@
+//$Id: TwinkleToes.java 14761 2008-06-11 13:51:06Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences.entities;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * Blown precision on related entity when @JoinColumn is used.
+ * Does not cause an issue on HyperSonic, but replicates nicely on PGSQL.
+ *
+ * @see ANN-748
+ * @author Andrew C. Oliver andyspam(a)osintegrators.com
+ */
+@Entity
+@SuppressWarnings("serial")
+public class TwinkleToes implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @Column(name = "id", precision = 128, scale = 0)
+ private BigInteger id;
+
+ @ManyToOne
+ Bunny bunny;
+
+ public void setBunny(Bunny bunny) {
+ this.bunny = bunny;
+ }
+
+ public BigInteger getId() {
+ return id;
+ }
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/package-info.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/package-info.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/package-info.java 2009-10-14 04:18:35 UTC (rev 17734)
@@ -0,0 +1,11 @@
+//$Id: package-info.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
+/**
+ * Test package for metatata facilities
+ * It contains an example of package level metadata
+ */
+(a)org.hibernate.annotations.GenericGenerator(name = "system-uuid", strategy = "uuid")
+(a)org.hibernate.annotations.GenericGenerators(
+ @org.hibernate.annotations.GenericGenerator(name = "system-uuid-2", strategy = "uuid")
+)
+package org.hibernate.test.annotations.id.sequences;
+
16 years, 2 months
Hibernate SVN: r17733 - jpa-api/trunk/src/main/java/javax/persistence/metamodel.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-13 16:56:34 -0400 (Tue, 13 Oct 2009)
New Revision: 17733
Modified:
jpa-api/trunk/src/main/java/javax/persistence/metamodel/IdentifiableType.java
jpa-api/trunk/src/main/java/javax/persistence/metamodel/ManagedType.java
Log:
validated javax.persistence.metamodel package definitions against spec version dated 2009.31.08
Modified: jpa-api/trunk/src/main/java/javax/persistence/metamodel/IdentifiableType.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/IdentifiableType.java 2009-10-13 19:59:53 UTC (rev 17732)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/IdentifiableType.java 2009-10-13 20:56:34 UTC (rev 17733)
@@ -19,25 +19,12 @@
* @return id attribute
*
* @throws IllegalArgumentException if id attribute of the given
- * type is not present in the identifiable type or if
- * the identifiable type has an id class
+ * type is not present in the identifiable type or if
+ * the identifiable type has an id class
*/
<Y> SingularAttribute<? super X, Y> getId(Class<Y> type);
/**
- * Return the attribute that corresponds to the version
- * attribute of the entity or mapped superclass.
- *
- * @param type the type of the represented version attribute
- *
- * @return version attribute
- *
- * @throws IllegalArgumentException if version attribute of the
- * given type is not present in the identifiable type
- */
- <Y> SingularAttribute<? super X, Y> getVersion(Class<Y> type);
-
- /**
* Return the attribute that corresponds to the id attribute
* declared by the entity or mapped superclass.
*
@@ -46,13 +33,26 @@
* @return declared id attribute
*
* @throws IllegalArgumentException if id attribute of the given
- * type is not declared in the identifiable type or if
- * the identifiable type has an id class
+ * type is not declared in the identifiable type or if
+ * the identifiable type has an id class
*/
<Y> SingularAttribute<X, Y> getDeclaredId(Class<Y> type);
/**
* Return the attribute that corresponds to the version
+ * attribute of the entity or mapped superclass.
+ *
+ * @param type the type of the represented version attribute
+ *
+ * @return version attribute
+ *
+ * @throws IllegalArgumentException if version attribute of the
+ * given type is not present in the identifiable type
+ */
+ <Y> SingularAttribute<? super X, Y> getVersion(Class<Y> type);
+
+ /**
+ * Return the attribute that corresponds to the version
* attribute declared by the entity or mapped superclass.
*
* @param type the type of the represented declared version
@@ -61,7 +61,7 @@
* @return declared version attribute
*
* @throws IllegalArgumentException if version attribute of the
- * type is not declared in the identifiable type
+ * type is not declared in the identifiable type
*/
<Y> SingularAttribute<X, Y> getDeclaredVersion(Class<Y> type);
@@ -80,7 +80,7 @@
* for an idclass.
*
* @return boolean indicating whether or not the identifiable
- * type has a single id attribute
+ * type has a single id attribute
*/
boolean hasSingleIdAttribute();
@@ -88,7 +88,7 @@
* Whether or not the identifiable type has a version attribute.
*
* @return boolean indicating whether or not the identifiable
- * type has a version attribute
+ * type has a version attribute
*/
boolean hasVersionAttribute();
@@ -99,7 +99,7 @@
* @return id attributes
*
* @throws IllegalArgumentException if the identifiable type
- * does not have an id class
+ * does not have an id class
*/
java.util.Set<SingularAttribute<? super X, ?>> getIdClassAttributes();
Modified: jpa-api/trunk/src/main/java/javax/persistence/metamodel/ManagedType.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/ManagedType.java 2009-10-13 19:59:53 UTC (rev 17732)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/ManagedType.java 2009-10-13 20:56:34 UTC (rev 17733)
@@ -12,11 +12,16 @@
/**
* Return the attributes of the managed type.
+ *
+ * @return The type's attributes
*/
java.util.Set<Attribute<? super X, ?>> getAttributes();
/**
* Return the attributes declared by the managed type.
+ * Returns empty set if the managed type has no declared attributes.
+ *
+ * @return The type's declared attributes, or empty set representing none.
*/
java.util.Set<Attribute<X, ?>> getDeclaredAttributes();
@@ -53,14 +58,15 @@
/**
* Return the single-valued attributes of the managed type.
+ * Returns empty set if the managed type has no single-valued attributes.
*
* @return single-valued attributes
*/
java.util.Set<SingularAttribute<? super X, ?>> getSingularAttributes();
/**
- * Return the single-valued attributes declared by the managed
- * type.
+ * Return the single-valued attributes declared by the managed type.
+ * Returns empty set if the managed type has no declared single-valued attributes.
*
* @return declared single-valued attributes
*/
@@ -83,86 +89,67 @@
<E> CollectionAttribute<? super X, E> getCollection(String name, Class<E> elementType);
/**
- * Return the Set-valued attribute of the managed type that
- * corresponds to the specified name and Java element type.
+ * Return the Collection-valued attribute declared by the
+ * managed type that corresponds to the specified name and Java
+ * element type.
*
* @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
*
- * @return SetAttribute of the given name and element type
+ * @return declared CollectionAttribute of the given name and
+ * element type
*
* @throws IllegalArgumentException if attribute of the given
- * name and type is not present in the managed type
+ * name and type is not declared in the managed type
*/
- <E> SetAttribute<? super X, E> getSet(String name, Class<E> elementType);
+ <E> CollectionAttribute<X, E> getDeclaredCollection(String name, Class<E> elementType);
/**
- * Return the List-valued attribute of the managed type that
+ * Return the Set-valued attribute of the managed type that
* corresponds to the specified name and Java element type.
*
* @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
*
- * @return ListAttribute of the given name and element type
+ * @return SetAttribute of the given name and element type
*
* @throws IllegalArgumentException if attribute of the given
* name and type is not present in the managed type
*/
- <E> ListAttribute<? super X, E> getList(String name, Class<E> elementType);
+ <E> SetAttribute<? super X, E> getSet(String name, Class<E> elementType);
/**
- * Return the Map-valued attribute of the managed type that
- * corresponds to the specified name and Java key and value
- * types.
+ * Return the Set-valued attribute declared by the managed type
+ * that corresponds to the specified name and Java element type.
*
* @param name the name of the represented attribute
- * @param keyType the key type of the represented attribute
- * @param valueType the value type of the represented attribute
- *
- * @return MapAttribute of the given name and key and value
- * types
- *
- * @throws IllegalArgumentException if attribute of the given
- * name and type is not present in the managed type
- */
- <K, V> MapAttribute<? super X, K, V> getMap(String name,
- Class<K> keyType,
- Class<V> valueType);
-
- /**
- * Return the Collection-valued attribute declared by the
- * managed type that corresponds to the specified name and Java
- * element type.
- *
- * @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
*
- * @return declared CollectionAttribute of the given name and
+ * @return declared SetAttribute of the given name and
* element type
*
* @throws IllegalArgumentException if attribute of the given
* name and type is not declared in the managed type
*/
- <E> CollectionAttribute<X, E> getDeclaredCollection(String name, Class<E> elementType);
+ <E> SetAttribute<X, E> getDeclaredSet(String name, Class<E> elementType);
/**
- * Return the Set-valued attribute declared by the managed type
- * that corresponds to the specified name and Java element type.
+ * Return the List-valued attribute of the managed type that
+ * corresponds to the specified name and Java element type.
*
* @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
*
- * @return declared SetAttribute of the given name and
- * element type
+ * @return ListAttribute of the given name and element type
*
* @throws IllegalArgumentException if attribute of the given
- * name and type is not declared in the managed type
+ * name and type is not present in the managed type
*/
- <E> SetAttribute<X, E> getDeclaredSet(String name, Class<E> elementType);
+ <E> ListAttribute<? super X, E> getList(String name, Class<E> elementType);
/**
* Return the List-valued attribute declared by the managed
@@ -182,6 +169,25 @@
<E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
/**
+ * Return the Map-valued attribute of the managed type that
+ * corresponds to the specified name and Java key and value
+ * types.
+ *
+ * @param name the name of the represented attribute
+ * @param keyType the key type of the represented attribute
+ * @param valueType the value type of the represented attribute
+ *
+ * @return MapAttribute of the given name and key and value
+ * types
+ *
+ * @throws IllegalArgumentException if attribute of the given
+ * name and type is not present in the managed type
+ */
+ <K, V> MapAttribute<? super X, K, V> getMap(String name,
+ Class<K> keyType,
+ Class<V> valueType);
+
+ /**
* Return the Map-valued attribute declared by the managed
* type that corresponds to the specified name and Java key
* and value types.
@@ -201,19 +207,26 @@
Class<V> valueType);
/**
- * Return all collection-valued attributes of the managed type.
+ * Return all multi-valued attributes (Collection-, Set-,
+ * List-, and Map-valued attributes) of the managed type.
+ * Returns empty set if the managed type has no multi-valued
+ * attributes.
*
- * @return collection valued attributes
+ * @return Collection-, Set-, List-, and Map-valued attributes
*/
- java.util.Set<PluralAttribute<? super X, ?, ?>> getCollections();
+ java.util.Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes();
/**
- * Return all collection-valued attributes declared by the
+ * Return all multi-valued attributes (Collection-, Set-,
+ * List-, and Map-valued attributes) declared by the
* managed type.
+ * Returns empty set if the managed type has no declared
+ * multi-valued attributes.
*
- * @return declared collection valued attributes
+ * @return declared Collection-, Set-, List-, and Map-valued
+ * attributes
*/
- java.util.Set<PluralAttribute<X, ?, ?>> getDeclaredCollections();
+ java.util.Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes();
//String-based:
@@ -285,82 +298,82 @@
CollectionAttribute<? super X, ?> getCollection(String name);
/**
- * Return the Set-valued attribute of the managed type that
- * corresponds to the specified name.
+ * Return the Collection-valued attribute declared by the
+ * managed type that corresponds to the specified name.
*
* @param name the name of the represented attribute
*
- * @return SetAttribute of the given name
+ * @return declared CollectionAttribute of the given name
*
* @throws IllegalArgumentException if attribute of the given
- * name is not present in the managed type
+ * name is not declared in the managed type
*/
- SetAttribute<? super X, ?> getSet(String name);
+ CollectionAttribute<X, ?> getDeclaredCollection(String name);
/**
- * Return the List-valued attribute of the managed type that
+ * Return the Set-valued attribute of the managed type that
* corresponds to the specified name.
*
* @param name the name of the represented attribute
*
- * @return ListAttribute of the given name
+ * @return SetAttribute of the given name
*
* @throws IllegalArgumentException if attribute of the given
* name is not present in the managed type
*/
- ListAttribute<? super X, ?> getList(String name);
+ SetAttribute<? super X, ?> getSet(String name);
/**
- * Return the Map-valued attribute of the managed type that
- * corresponds to the specified name.
+ * Return the Set-valued attribute declared by the managed type
+ * that corresponds to the specified name.
*
* @param name the name of the represented attribute
*
- * @return MapAttribute of the given name
+ * @return declared SetAttribute of the given name
*
* @throws IllegalArgumentException if attribute of the given
- * name is not present in the managed type
+ * name is not declared in the managed type
*/
- MapAttribute<? super X, ?, ?> getMap(String name);
+ SetAttribute<X, ?> getDeclaredSet(String name);
/**
- * Return the Collection-valued attribute declared by the
- * managed type that corresponds to the specified name.
+ * Return the List-valued attribute of the managed type that
+ * corresponds to the specified name.
*
* @param name the name of the represented attribute
*
- * @return declared CollectionAttribute of the given name
+ * @return ListAttribute of the given name
*
* @throws IllegalArgumentException if attribute of the given
- * name is not declared in the managed type
+ * name is not present in the managed type
*/
- CollectionAttribute<X, ?> getDeclaredCollection(String name);
+ ListAttribute<? super X, ?> getList(String name);
/**
- * Return the Set-valued attribute declared by the managed type
- * that corresponds to the specified name.
+ * Return the List-valued attribute declared by the managed
+ * type that corresponds to the specified name.
*
* @param name the name of the represented attribute
*
- * @return declared SetAttribute of the given name
+ * @return declared ListAttribute of the given name
*
* @throws IllegalArgumentException if attribute of the given
* name is not declared in the managed type
*/
- SetAttribute<X, ?> getDeclaredSet(String name);
+ ListAttribute<X, ?> getDeclaredList(String name);
/**
- * Return the List-valued attribute declared by the managed
- * type that corresponds to the specified name.
+ * Return the Map-valued attribute of the managed type that
+ * corresponds to the specified name.
*
* @param name the name of the represented attribute
*
- * @return declared ListAttribute of the given name
+ * @return MapAttribute of the given name
*
* @throws IllegalArgumentException if attribute of the given
- * name is not declared in the managed type
+ * name is not present in the managed type
*/
- ListAttribute<X, ?> getDeclaredList(String name);
+ MapAttribute<? super X, ?, ?> getMap(String name);
/**
* Return the Map-valued attribute declared by the managed
16 years, 2 months
Hibernate SVN: r17732 - in core/branches/Branch_3_3/cache-jbosscache2/src: main/java/org/hibernate/cache/jbc2/access and 10 other directories.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2009-10-13 15:59:53 -0400 (Tue, 13 Oct 2009)
New Revision: 17732
Modified:
core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/BasicRegionAdapter.java
core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/access/OptimisticTransactionalAccessDelegate.java
core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/access/TransactionalAccessDelegate.java
core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/CollectionRegionImpl.java
core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/EntityRegionImpl.java
core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/query/QueryResultsRegionImpl.java
core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/timestamp/TimestampsRegionImpl.java
core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/util/CacheHelper.java
core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractGeneralDataRegionTestCase.java
core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java
core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java
core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java
core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractTransactionalAccessTestCase.java
core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/bulk/PessimisticBulkOperationsTest.java
core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/optimistic-treecache.xml
core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/pessimistic-treecache.xml
Log:
[HHH-3818] Properly handle Entity/CollectionRegionAccessStrategy evict
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/BasicRegionAdapter.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/BasicRegionAdapter.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/BasicRegionAdapter.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -23,9 +23,13 @@
*/
package org.hibernate.cache.jbc2;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -42,7 +46,12 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeInvalidated;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.annotation.ViewChanged;
+import org.jboss.cache.notifications.event.NodeInvalidatedEvent;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.notifications.event.ViewChangedEvent;
import org.jboss.cache.optimistic.DataVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,30 +62,52 @@
*
* @author Steve Ebersole
*/
-@CacheListener
public abstract class BasicRegionAdapter implements Region {
+ private enum InvalidateState { INVALID, CLEARING, VALID };
public static final String ITEM = CacheHelper.ITEM;
protected final Cache jbcCache;
protected final String regionName;
protected final Fqn regionFqn;
+ protected final Fqn internalFqn;
protected Node regionRoot;
protected final boolean optimistic;
protected final TransactionManager transactionManager;
protected final Logger log;
protected final Object regionRootMutex = new Object();
+ protected final Object memberId;
+ protected final boolean replication;
+ protected final Object invalidationMutex = new Object();
+ protected final AtomicReference<InvalidateState> invalidateState =
+ new AtomicReference<InvalidateState>(InvalidateState.VALID);
+ protected final Set<Object> currentView = new HashSet<Object>();
// protected RegionRootListener listener;
public BasicRegionAdapter(Cache jbcCache, String regionName, String regionPrefix) {
+
+ this.log = LoggerFactory.getLogger(getClass());
+
this.jbcCache = jbcCache;
this.transactionManager = jbcCache.getConfiguration().getRuntimeConfig().getTransactionManager();
this.regionName = regionName;
this.regionFqn = createRegionFqn(regionName, regionPrefix);
- optimistic = jbcCache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
- log = LoggerFactory.getLogger(getClass());
+ this.internalFqn = CacheHelper.getInternalFqn(regionFqn);
+ this.optimistic = jbcCache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
+ this.memberId = jbcCache.getLocalAddress();
+ this.replication = CacheHelper.isClusteredReplication(jbcCache);
+
+ this.jbcCache.addCacheListener(this);
+
+ synchronized (currentView) {
+ List view = jbcCache.getMembers();
+ if (view != null) {
+ currentView.addAll(view);
+ }
+ }
+
activateLocalClusterNode();
log.debug("Created Region for " + regionName + " -- regionPrefix is " + regionPrefix);
@@ -129,13 +160,13 @@
if (!regionRoot.isResident()) {
regionRoot.setResident(true);
}
+ establishInternalNodes();
}
catch (Exception e) {
throw new CacheException(e.getMessage(), e);
}
finally {
- if (tx != null)
- resume(tx);
+ resume(tx);
}
}
@@ -154,6 +185,7 @@
// For pessimistic locking, we just want to toss out our ref
// to any old invalid root node and get the latest (may be null)
if (!optimistic) {
+ establishInternalNodes();
regionRoot = jbcCache.getRoot().getChild( regionFqn );
return;
}
@@ -181,6 +213,7 @@
}
// Never evict this node
newRoot.setResident(true);
+ establishInternalNodes();
}
finally {
resume(tx);
@@ -189,6 +222,24 @@
}
}
+ private void establishInternalNodes()
+ {
+ synchronized (currentView) {
+ Transaction tx = suspend();
+ try {
+ for (Object member : currentView) {
+ DataVersion version = optimistic ? NonLockingDataVersion.INSTANCE : null;
+ Fqn f = Fqn.fromRelativeElements(internalFqn, member);
+ CacheHelper.addNode(jbcCache, f, true, false, version);
+ }
+ }
+ finally {
+ resume(tx);
+ }
+ }
+
+ }
+
public String getName() {
return regionName;
}
@@ -201,6 +252,11 @@
return regionFqn;
}
+ public Object getMemberId()
+ {
+ return this.memberId;
+ }
+
/**
* Checks for the validity of the root cache node for this region,
* creating a new one if it does not exist or is invalid, and also
@@ -219,6 +275,37 @@
if (regionRoot != null && regionRoot.isValid() && !regionRoot.isResident())
regionRoot.setResident(true);
}
+
+ public boolean checkValid()
+ {
+ boolean valid = invalidateState.get() == InvalidateState.VALID;
+
+ if (!valid) {
+ synchronized (invalidationMutex) {
+ if (invalidateState.compareAndSet(InvalidateState.INVALID, InvalidateState.CLEARING)) {
+ Transaction tx = suspend();
+ try {
+ Option opt = new Option();
+ opt.setLockAcquisitionTimeout(1);
+ opt.setCacheModeLocal(true);
+ CacheHelper.removeAll(jbcCache, regionFqn, opt);
+ invalidateState.compareAndSet(InvalidateState.CLEARING, InvalidateState.VALID);
+ }
+ catch (Exception e) {
+ if (log.isTraceEnabled()) {
+ log.trace("Could not invalidate region: " + e.getLocalizedMessage());
+ }
+ }
+ finally {
+ resume(tx);
+ }
+ }
+ }
+ valid = invalidateState.get() == InvalidateState.VALID;
+ }
+
+ return valid;
+ }
public void destroy() throws CacheException {
try {
@@ -242,10 +329,9 @@
} catch (Exception e) {
throw new CacheException(e);
}
-// finally {
-// if (listener != null)
-// jbcCache.removeCacheListener(listener);
-// }
+ finally {
+ jbcCache.removeCacheListener(this);
+ }
}
protected void deactivateLocalNode() {
@@ -256,18 +342,50 @@
}
}
+ public boolean contains(Object key) {
+ if ( !checkValid() ) {
+ return false;
+ }
+
+ try {
+ Option opt = new Option();
+ opt.setLockAcquisitionTimeout(100);
+ CacheHelper.setInvocationOption( jbcCache, opt );
+ return CacheHelper.getAllowingTimeout( jbcCache, regionFqn, key ) != null;
+ }
+ catch ( CacheException ce ) {
+ throw ce;
+ }
+ catch ( Throwable t ) {
+ throw new CacheException( t );
+ }
+ }
+
public long getSizeInMemory() {
// not supported
return -1;
}
public long getElementCountInMemory() {
- try {
- Set childrenNames = CacheHelper.getChildrenNames(jbcCache, regionFqn);
- return childrenNames.size();
- } catch (Exception e) {
- throw new CacheException(e);
+ if (checkValid()) {
+ try {
+ Set childrenNames = CacheHelper.getChildrenNames(jbcCache, regionFqn);
+ int size = childrenNames.size();
+ if (childrenNames.contains(CacheHelper.Internal.NODE)) {
+ size--;
+ }
+ return size;
+ }
+ catch ( CacheException ce ) {
+ throw ce;
+ }
+ catch (Exception e) {
+ throw new CacheException(e);
+ }
}
+ else {
+ return 0;
+ }
}
public long getElementCountOnDisk() {
@@ -275,18 +393,25 @@
}
public Map toMap() {
- try {
- Map result = new HashMap();
- Set childrenNames = CacheHelper.getChildrenNames(jbcCache, regionFqn);
- for (Object childName : childrenNames) {
- result.put(childName, CacheHelper.get(jbcCache,regionFqn, childName));
- }
- return result;
- } catch (CacheException e) {
- throw e;
- } catch (Exception e) {
- throw new CacheException(e);
+ if (checkValid()) {
+ try {
+ Map result = new HashMap();
+ Set childrenNames = CacheHelper.getChildrenNames(jbcCache, regionFqn);
+ for (Object childName : childrenNames) {
+ if (CacheHelper.Internal.NODE != childName) {
+ result.put(childName, CacheHelper.get(jbcCache,regionFqn, childName));
+ }
+ }
+ return result;
+ } catch (CacheException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new CacheException(e);
+ }
}
+ else {
+ return Collections.emptyMap();
+ }
}
public long nextTimestamp() {
@@ -327,7 +452,7 @@
* @return the transaction that was suspended, or <code>null</code> if
* there wasn't one
*/
- protected Transaction suspend() {
+ public Transaction suspend() {
Transaction tx = null;
try {
if (transactionManager != null) {
@@ -345,7 +470,7 @@
* @param tx
* the transaction to suspend. May be <code>null</code>.
*/
- protected void resume(Transaction tx) {
+ public void resume(Transaction tx) {
try {
if (tx != null)
transactionManager.resume(tx);
@@ -404,17 +529,52 @@
return escaped;
}
-// @CacheListener
-// public class RegionRootListener {
-//
-// @NodeCreated
-// public void nodeCreated(NodeCreatedEvent event) {
-// if (!event.isPre() && event.getFqn().equals(getRegionFqn())) {
-// log.debug("Node created for " + getRegionFqn());
-// Node regionRoot = jbcCache.getRoot().getChild(getRegionFqn());
-// regionRoot.setResident(true);
-// }
-// }
-//
-// }
+ @NodeModified
+ public void nodeModified(NodeModifiedEvent event)
+ {
+ handleEvictAllModification(event);
+ }
+
+ protected boolean handleEvictAllModification(NodeModifiedEvent event) {
+
+ if (!event.isPre() && (replication || event.isOriginLocal()) && event.getData().containsKey(ITEM))
+ {
+ if (event.getFqn().isChildOf(internalFqn))
+ {
+ invalidateState.set(InvalidateState.INVALID);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @NodeInvalidated
+ public void nodeInvalidated(NodeInvalidatedEvent event)
+ {
+ handleEvictAllInvalidation(event);
+ }
+
+ protected boolean handleEvictAllInvalidation(NodeInvalidatedEvent event)
+ {
+ if (!event.isPre() && event.getFqn().isChildOf(internalFqn))
+ {
+ invalidateState.set(InvalidateState.INVALID);
+ return true;
+ }
+ return false;
+ }
+
+ @ViewChanged
+ public void viewChanged(ViewChangedEvent event) {
+
+ synchronized (currentView) {
+ List view = event.getNewView().getMembers();
+ if (view != null) {
+ currentView.addAll(view);
+ establishInternalNodes();
+ }
+ }
+
+ }
+
}
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/access/OptimisticTransactionalAccessDelegate.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/access/OptimisticTransactionalAccessDelegate.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/access/OptimisticTransactionalAccessDelegate.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -23,11 +23,12 @@
*/
package org.hibernate.cache.jbc2.access;
+import javax.transaction.Transaction;
+
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.access.CollectionRegionAccessStrategy;
import org.hibernate.cache.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.jbc2.BasicRegionAdapter;
import org.hibernate.cache.jbc2.TransactionalDataRegionAdapter;
import org.hibernate.cache.jbc2.util.CacheHelper;
import org.hibernate.cache.jbc2.util.DataVersionAdapter;
@@ -75,22 +76,17 @@
* by adding a {@link NonLockingDataVersion} to the invocation.
*/
@Override
- public void evictAll() throws CacheException {
-
- evictOrRemoveAll();
- }
-
- /**
- * Overrides the {@link TransactionalAccessDelegate#get(Object, long) superclass}
- * by {@link BasicRegionAdapter#ensureRegionRootExists() ensuring the root
- * node for the region exists} before making the call.
- */
- @Override
- public Object get(Object key, long txTimestamp) throws CacheException
+ public void evictAll() throws CacheException
{
- region.ensureRegionRootExists();
-
- return CacheHelper.get(cache, regionFqn, key);
+ Transaction tx = region.suspend();
+ try {
+ region.ensureRegionRootExists();
+ Option opt = NonLockingDataVersion.getInvocationOption();
+ CacheHelper.sendEvictAllNotification(cache, regionFqn, region.getMemberId(), opt);
+ }
+ finally {
+ region.resume(tx);
+ }
}
/**
@@ -100,6 +96,9 @@
*/
@Override
public boolean insert(Object key, Object value, Object version) throws CacheException {
+
+ if (!region.checkValid())
+ return false;
region.ensureRegionRootExists();
@@ -111,6 +110,9 @@
@Override
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
throws CacheException {
+
+ if (!region.checkValid())
+ return false;
region.ensureRegionRootExists();
@@ -123,6 +125,9 @@
@Override
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
+
+ if (!region.checkValid())
+ return false;
region.ensureRegionRootExists();
@@ -132,6 +137,10 @@
@Override
public void remove(Object key) throws CacheException {
+
+ // We remove whether or not the region is valid. Other nodes
+ // may have already restored the region so they need to
+ // be informed of the change.
region.ensureRegionRootExists();
@@ -141,14 +150,18 @@
@Override
public void removeAll() throws CacheException {
-
- evictOrRemoveAll();
+ Option opt = NonLockingDataVersion.getInvocationOption();
+ CacheHelper.removeAll(cache, regionFqn, opt);
}
@Override
public boolean update(Object key, Object value, Object currentVersion, Object previousVersion)
throws CacheException {
+ // We update whether or not the region is valid. Other nodes
+ // may have already restored the region so they need to
+ // be informed of the change.
+
region.ensureRegionRootExists();
Option opt = getDataVersionOption(currentVersion, previousVersion);
@@ -166,10 +179,4 @@
return opt;
}
- private void evictOrRemoveAll() {
-
- Option opt = NonLockingDataVersion.getInvocationOption();
- CacheHelper.removeAll(cache, regionFqn, opt);
- }
-
}
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/access/TransactionalAccessDelegate.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/access/TransactionalAccessDelegate.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/access/TransactionalAccessDelegate.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -23,6 +23,8 @@
*/
package org.hibernate.cache.jbc2.access;
+import javax.transaction.Transaction;
+
import org.hibernate.cache.CacheException;
import org.hibernate.cache.access.CollectionRegionAccessStrategy;
import org.hibernate.cache.access.EntityRegionAccessStrategy;
@@ -56,14 +58,20 @@
}
public Object get(Object key, long txTimestamp) throws CacheException {
-
+
+ if (!region.checkValid())
+ return null;
+
region.ensureRegionRootExists();
return CacheHelper.get(cache, regionFqn, key);
}
- public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
+ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
+ if (!region.checkValid())
+ return false;
+
region.ensureRegionRootExists();
return CacheHelper.putForExternalRead(cache, regionFqn, key, value);
@@ -72,6 +80,9 @@
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
throws CacheException {
+ if (!region.checkValid())
+ return false;
+
region.ensureRegionRootExists();
// We ignore minimalPutOverride. JBossCache putForExternalRead is
@@ -96,6 +107,9 @@
public boolean insert(Object key, Object value, Object version) throws CacheException {
+ if (!region.checkValid())
+ return false;
+
region.ensureRegionRootExists();
CacheHelper.put(cache, regionFqn, key, value);
@@ -109,6 +123,10 @@
public boolean update(Object key, Object value, Object currentVersion, Object previousVersion)
throws CacheException {
+ // We update whether or not the region is valid. Other nodes
+ // may have already restored the region so they need to
+ // be informed of the change.
+
region.ensureRegionRootExists();
CacheHelper.put(cache, regionFqn, key, value);
@@ -122,13 +140,17 @@
public void remove(Object key) throws CacheException {
+ // We remove whether or not the region is valid. Other nodes
+ // may have already restored the region so they need to
+ // be informed of the change.
+
region.ensureRegionRootExists();
CacheHelper.remove(cache, regionFqn, key);
}
public void removeAll() throws CacheException {
- evictOrRemoveAll();
+ CacheHelper.removeAll(cache, regionFqn);
}
public void evict(Object key) throws CacheException {
@@ -139,10 +161,15 @@
}
public void evictAll() throws CacheException {
- evictOrRemoveAll();
+ Transaction tx = region.suspend();
+ try {
+ region.ensureRegionRootExists();
+
+ CacheHelper.sendEvictAllNotification(cache, regionFqn, region.getMemberId(), null);
+ }
+ finally {
+ region.resume(tx);
+ }
}
- private void evictOrRemoveAll() throws CacheException {
- CacheHelper.removeAll(cache, regionFqn);
- }
}
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/CollectionRegionImpl.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/CollectionRegionImpl.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/CollectionRegionImpl.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -26,6 +26,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.notifications.annotation.CacheListener;
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.CacheException;
@@ -39,6 +40,7 @@
*
* @author Steve Ebersole
*/
+@CacheListener
public class CollectionRegionImpl extends TransactionalDataRegionAdapter implements CollectionRegion {
public static final String TYPE = "COLL";
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/EntityRegionImpl.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/EntityRegionImpl.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/EntityRegionImpl.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -26,6 +26,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.notifications.annotation.CacheListener;
import org.hibernate.cache.CacheDataDescription;
import org.hibernate.cache.CacheException;
@@ -39,6 +40,7 @@
*
* @author Steve Ebersole
*/
+@CacheListener
public class EntityRegionImpl extends TransactionalDataRegionAdapter implements EntityRegion {
public static final String TYPE = "ENTITY";
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/query/QueryResultsRegionImpl.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/query/QueryResultsRegionImpl.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/query/QueryResultsRegionImpl.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -25,6 +25,8 @@
import java.util.Properties;
+import javax.transaction.Transaction;
+
import org.hibernate.cache.CacheException;
import org.hibernate.cache.QueryResultsRegion;
import org.hibernate.cache.jbc2.TransactionalDataRegionAdapter;
@@ -33,6 +35,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Option;
+import org.jboss.cache.notifications.annotation.CacheListener;
/**
* Defines the behavior of the query cache regions for JBossCache 2.x.
@@ -40,6 +43,7 @@
* @author Brian Stansberry
* @version $Revision$
*/
+@CacheListener
public class QueryResultsRegionImpl extends TransactionalDataRegionAdapter implements QueryResultsRegion {
public static final String QUERY_CACHE_LOCAL_ONLY_PROP = "hibernate.cache.region.jbc2.query.localonly";
@@ -85,14 +89,22 @@
}
public void evictAll() throws CacheException {
- Option opt = getNonLockingDataVersionOption(false);
- if (localOnly)
- opt.setCacheModeLocal(true);
- CacheHelper.removeAll(getCacheInstance(), getRegionFqn(), opt);
+ Transaction tx = suspend();
+ try {
+ ensureRegionRootExists();
+ Option opt = getNonLockingDataVersionOption(true);
+ CacheHelper.sendEvictAllNotification(jbcCache, regionFqn, getMemberId(), opt);
+ }
+ finally {
+ resume(tx);
+ }
}
public Object get(Object key) throws CacheException {
+ if (!checkValid())
+ return null;
+
ensureRegionRootExists();
// Don't hold the JBC node lock throughout the tx, as that
@@ -106,28 +118,30 @@
public void put(Object key, Object value) throws CacheException {
- ensureRegionRootExists();
-
- // Here we don't want to suspend the tx. If we do:
- // 1) We might be caching query results that reflect uncommitted
- // changes. No tx == no WL on cache node, so other threads
- // can prematurely see those query results
- // 2) No tx == immediate replication. More overhead, plus we
- // spread issue #1 above around the cluster
-
- // Add a zero (or quite low) timeout option so we don't block.
- // Ignore any TimeoutException. Basically we forego caching the
- // query result in order to avoid blocking.
- // Reads are done with suspended tx, so they should not hold the
- // lock for long. Not caching the query result is OK, since
- // any subsequent read will just see the old result with its
- // out-of-date timestamp; that result will be discarded and the
- // db query performed again.
- Option opt = getNonLockingDataVersionOption(false);
- opt.setLockAcquisitionTimeout(2);
- if (localOnly)
- opt.setCacheModeLocal(true);
- CacheHelper.putAllowingTimeout(getCacheInstance(), getRegionFqn(), key, value, opt);
+ if (checkValid()) {
+ ensureRegionRootExists();
+
+ // Here we don't want to suspend the tx. If we do:
+ // 1) We might be caching query results that reflect uncommitted
+ // changes. No tx == no WL on cache node, so other threads
+ // can prematurely see those query results
+ // 2) No tx == immediate replication. More overhead, plus we
+ // spread issue #1 above around the cluster
+
+ // Add a zero (or quite low) timeout option so we don't block.
+ // Ignore any TimeoutException. Basically we forego caching the
+ // query result in order to avoid blocking.
+ // Reads are done with suspended tx, so they should not hold the
+ // lock for long. Not caching the query result is OK, since
+ // any subsequent read will just see the old result with its
+ // out-of-date timestamp; that result will be discarded and the
+ // db query performed again.
+ Option opt = getNonLockingDataVersionOption(false);
+ opt.setLockAcquisitionTimeout(2);
+ if (localOnly)
+ opt.setCacheModeLocal(true);
+ CacheHelper.putAllowingTimeout(getCacheInstance(), getRegionFqn(), key, value, opt);
+ }
}
@Override
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/timestamp/TimestampsRegionImpl.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/timestamp/TimestampsRegionImpl.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/timestamp/TimestampsRegionImpl.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -41,6 +41,7 @@
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeModified;
import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.NodeInvalidatedEvent;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.notifications.event.NodeRemovedEvent;
@@ -95,14 +96,21 @@
public void evictAll() throws CacheException {
// TODO Is this a valid operation on a timestamps cache?
- Option opt = getNonLockingDataVersionOption(true);
- CacheHelper.removeAll(getCacheInstance(), getRegionFqn(), opt);
+ Transaction tx = suspend();
+ try {
+ ensureRegionRootExists();
+ Option opt = getNonLockingDataVersionOption(true);
+ CacheHelper.sendEvictAllNotification(jbcCache, regionFqn, getMemberId(), opt);
+ }
+ finally {
+ resume(tx);
+ }
}
public Object get(Object key) throws CacheException {
Object value = localCache.get(key);
- if (value == null) {
+ if (value == null && checkValid()) {
ensureRegionRootExists();
@@ -147,14 +155,15 @@
*/
@NodeModified
public void nodeModified(NodeModifiedEvent event) {
- if (event.isPre())
- return;
-
- Fqn fqn = event.getFqn();
- Fqn regFqn = getRegionFqn();
- if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) {
- Object key = fqn.get(regFqn.size());
- localCache.put(key, event.getData().get(ITEM));
+
+ if (!handleEvictAllModification(event) && !event.isPre()) {
+
+ Fqn fqn = event.getFqn();
+ Fqn regFqn = getRegionFqn();
+ if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) {
+ Object key = fqn.get(regFqn.size());
+ localCache.put(key, event.getData().get(ITEM));
+ }
}
}
@@ -178,8 +187,30 @@
localCache.clear();
}
}
+
+
- /**
+ @Override
+ protected boolean handleEvictAllInvalidation(NodeInvalidatedEvent event)
+ {
+ boolean result = super.handleEvictAllInvalidation(event);
+ if (result) {
+ localCache.clear();
+ }
+ return result;
+ }
+
+ @Override
+ protected boolean handleEvictAllModification(NodeModifiedEvent event)
+ {
+ boolean result = super.handleEvictAllModification(event);
+ if (result) {
+ localCache.clear();
+ }
+ return result;
+ }
+
+ /**
* Brings all data from the distributed cache into our local cache.
*/
private void populateLocalCache() {
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/util/CacheHelper.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/util/CacheHelper.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/util/CacheHelper.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -46,6 +46,8 @@
*/
public class CacheHelper {
+ public static enum Internal { NODE, LOCAL };
+
/** Key under which items are cached */
public static final String ITEM = "item";
/** Key and value used in a hack to create region root nodes */
@@ -467,4 +469,23 @@
option.setDataVersion(version);
setInvocationOption(cache, option);
}
+
+ public static Fqn getInternalFqn(Fqn region)
+ {
+ return Fqn.fromRelativeElements(region, Internal.NODE);
+ }
+
+ public static void sendEvictNotification(Cache cache, Fqn region, Object member, Object key, Option option)
+ {
+ setInvocationOption(cache, option);
+ Fqn f = Fqn.fromRelativeElements(region, Internal.NODE, member == null ? Internal.LOCAL : member, key);
+ cache.put(f, ITEM, DUMMY);
+ }
+
+ public static void sendEvictAllNotification(Cache cache, Fqn region, Object member, Option option)
+ {
+ setInvocationOption(cache, option);
+ Fqn f = Fqn.fromRelativeElements(region, Internal.NODE, member == null ? Internal.LOCAL : member);
+ cache.put(f, ITEM, DUMMY);
+ }
}
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractGeneralDataRegionTestCase.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractGeneralDataRegionTestCase.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractGeneralDataRegionTestCase.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -24,9 +24,7 @@
package org.hibernate.test.cache.jbc2;
import java.util.Iterator;
-import java.util.Set;
-import org.hibernate.cache.CacheException;
import org.hibernate.cache.GeneralDataRegion;
import org.hibernate.cache.QueryResultsRegion;
import org.hibernate.cache.Region;
@@ -171,8 +169,7 @@
Node regionRoot = localCache.getRoot().getChild(regionFqn);
assertFalse(regionRoot == null);
- Set children = regionRoot.getChildrenNames();
- assertEquals("No children in " + children, 0, children.size());
+ assertEquals("No children in " + regionRoot, 0, getValidChildrenCount(regionRoot));
assertTrue(regionRoot.isResident());
if (optimistic) {
@@ -181,7 +178,7 @@
regionRoot = remoteCache.getRoot().getChild(regionFqn);
assertFalse(regionRoot == null);
- assertEquals(0, regionRoot.getChildrenNames().size());
+ assertEquals(0, getValidChildrenCount(regionRoot));
assertTrue(regionRoot.isResident());
if (optimistic) {
@@ -212,35 +209,24 @@
localRegion.evictAll();
- // This should re-establish the region root node in the optimistic case
+ // This should re-establish the region root node
assertNull(localRegion.get(KEY));
regionRoot = localCache.getRoot().getChild(regionFqn);
- if (optimistic) {
- assertFalse(regionRoot == null);
- assertEquals(0, regionRoot.getChildrenNames().size());
- assertTrue(regionRoot.isValid());
- assertTrue(regionRoot.isResident());
- }
- else {
- assertTrue("region root is removed", regionRoot == null || !regionRoot.isValid());
- }
+ assertFalse(regionRoot == null);
+ assertEquals(0, getValidChildrenCount(regionRoot));
+ assertTrue(regionRoot.isValid());
+ assertTrue(regionRoot.isResident());
// Re-establishing the region root on the local node doesn't
// propagate it to other nodes. Do a get on the remote node to re-establish
- // This only adds a node in the case of optimistic locking
assertEquals(null, remoteRegion.get(KEY));
regionRoot = remoteCache.getRoot().getChild(regionFqn);
- if (optimistic) {
- assertFalse(regionRoot == null);
- assertEquals(0, regionRoot.getChildrenNames().size());
- assertTrue(regionRoot.isValid());
- assertTrue(regionRoot.isResident());
- }
- else {
- assertTrue("region root is removed", regionRoot == null || !regionRoot.isValid());
- }
+ assertFalse(regionRoot == null);
+ assertEquals(0, getValidChildrenCount(regionRoot));
+ assertTrue(regionRoot.isValid());
+ assertTrue(regionRoot.isResident());
assertEquals("local is clean", null, localRegion.get(KEY));
assertEquals("remote is clean", null, remoteRegion.get(KEY));
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -25,10 +25,14 @@
+import java.util.Set;
+
import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.jbc2.util.CacheHelper;
import org.hibernate.junit.UnitTestCase;
import org.hibernate.test.util.CacheTestSupport;
import org.jboss.cache.Cache;
+import org.jboss.cache.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,4 +100,15 @@
protected void avoidConcurrentFlush() {
testSupport.avoidConcurrentFlush();
}
+
+ protected int getValidChildrenCount(Node node) {
+ int result = 0;
+ Set<Node> children = node.getChildren();
+ for (Node child : children) {
+ if (node.isValid() && CacheHelper.Internal.NODE.equals(child.getFqn().getLastElement()) == false) {
+ result++;
+ }
+ }
+ return result;
+ }
}
\ No newline at end of file
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -471,38 +471,27 @@
localAccessStrategy.evictAll();
else
localAccessStrategy.removeAll();
-
- // This should re-establish the region root node in the optimistic case
+
+ // This should re-establish the region root node
assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis()));
regionRoot = localCache.getRoot().getChild(regionFqn);
- if (isUsingOptimisticLocking()) {
- assertFalse(regionRoot == null);
- assertEquals(0, getValidChildrenCount(regionRoot));
- assertTrue(regionRoot.isValid());
- assertTrue(regionRoot.isResident());
- }
- else {
- assertTrue("region root is removed", regionRoot == null || !regionRoot.isValid());
- }
+ assertFalse(regionRoot == null);
+ assertEquals(0, getValidChildrenCount(regionRoot));
+ assertTrue(regionRoot.isValid());
+ assertTrue(regionRoot.isResident());
// Re-establishing the region root on the local node doesn't
// propagate it to other nodes. Do a get on the remote node to re-establish
- // This only adds a node in the case of optimistic locking
assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
regionRoot = remoteCache.getRoot().getChild(regionFqn);
- if (isUsingOptimisticLocking()) {
- assertFalse(regionRoot == null);
- assertTrue(regionRoot.isValid());
- assertTrue(regionRoot.isResident());
- // Not invalidation, so we didn't insert a child above
- assertEquals(0, getValidChildrenCount(regionRoot));
- }
- else {
- assertTrue("region root is removed", regionRoot == null || !regionRoot.isValid());
- }
-
+ assertFalse(regionRoot == null);
+ assertTrue(regionRoot.isValid());
+ assertTrue(regionRoot.isResident());
+ // Not invalidation, so we didn't insert a child above
+ assertEquals(0, getValidChildrenCount(regionRoot));
+
// Test whether the get above messes up the optimistic version
remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1));
assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
@@ -521,17 +510,7 @@
assertEquals("local is correct", (isUsingInvalidation() ? null : VALUE1), localAccessStrategy.get(KEY, System.currentTimeMillis()));
assertEquals("remote is correct", VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
}
-
- private int getValidChildrenCount(Node node) {
- int result = 0;
- for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
- if (((Node) it.next()).isValid()) {
- result++;
- }
- }
- return result;
- }
-
+
private void rollback() {
try {
BatchModeTransactionManager.getInstance().rollback();
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -682,36 +682,26 @@
else
localAccessStrategy.removeAll();
- // This should re-establish the region root node in the optimistic case
+ // This should re-establish the region root node
assertNull(localAccessStrategy.get(KEY, System.currentTimeMillis()));
regionRoot = localCache.getRoot().getChild(regionFqn);
- if (isUsingOptimisticLocking()) {
- assertFalse(regionRoot == null);
- assertEquals(0, getValidChildrenCount(regionRoot));
- assertTrue(regionRoot.isValid());
- assertTrue(regionRoot.isResident());
- }
- else {
- assertTrue("region root is removed", regionRoot == null || !regionRoot.isValid());
- }
+ assertFalse(regionRoot == null);
+ assertEquals(0, getValidChildrenCount(regionRoot));
+ assertTrue(regionRoot.isValid());
+ assertTrue(regionRoot.isResident());
// Re-establishing the region root on the local node doesn't
// propagate it to other nodes. Do a get on the remote node to re-establish
assertEquals(null, remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
regionRoot = remoteCache.getRoot().getChild(regionFqn);
- if (isUsingOptimisticLocking()) {
- assertFalse(regionRoot == null);
- assertTrue(regionRoot.isValid());
- assertTrue(regionRoot.isResident());
- // Not invalidation, so we didn't insert a child above
- assertEquals(0, getValidChildrenCount(regionRoot));
- }
- else {
- assertTrue("region root is removed", regionRoot == null || !regionRoot.isValid());
- }
-
+ assertFalse(regionRoot == null);
+ assertTrue(regionRoot.isValid());
+ assertTrue(regionRoot.isResident());
+ // Not invalidation, so we didn't insert a child above
+ assertEquals(0, getValidChildrenCount(regionRoot));
+
// Test whether the get above messes up the optimistic version
remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1));
assertEquals(VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
@@ -730,17 +720,7 @@
assertEquals("local is correct", (isUsingInvalidation() ? null : VALUE1), localAccessStrategy.get(KEY, System.currentTimeMillis()));
assertEquals("remote is correct", VALUE1, remoteAccessStrategy.get(KEY, System.currentTimeMillis()));
}
-
- private int getValidChildrenCount(Node node) {
- int result = 0;
- for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
- if (((Node) it.next()).isValid()) {
- result++;
- }
- }
- return result;
- }
-
+
protected void rollback() {
try {
BatchModeTransactionManager.getInstance().rollback();
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractTransactionalAccessTestCase.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractTransactionalAccessTestCase.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractTransactionalAccessTestCase.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -63,7 +63,7 @@
final CountDownLatch commitLatch = new CountDownLatch(1);
final CountDownLatch completionLatch = new CountDownLatch(1);
- Thread blocker = new Thread() {
+ Thread blocker = new Thread("Blocker") {
public void run() {
@@ -95,7 +95,7 @@
}
};
- Thread putter = new Thread() {
+ Thread putter = new Thread("Putter") {
public void run() {
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/bulk/PessimisticBulkOperationsTest.java
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/bulk/PessimisticBulkOperationsTest.java 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/bulk/PessimisticBulkOperationsTest.java 2009-10-13 19:59:53 UTC (rev 17732)
@@ -26,11 +26,11 @@
import java.util.Set;
import org.hibernate.FlushMode;
-import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.jbc2.MultiplexedJBossCacheRegionFactory;
import org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;
+import org.hibernate.stat.SecondLevelCacheStatistics;
import org.hibernate.test.cache.jbc2.functional.CacheTestCaseBase;
import org.hibernate.test.cache.jbc2.functional.Contact;
import org.hibernate.test.cache.jbc2.functional.Customer;
@@ -90,7 +90,12 @@
assertNotNull("Red Hat contacts exist", rhContacts);
assertEquals("Created expected number of Red Hat contacts", 10, rhContacts.size());
+ SecondLevelCacheStatistics contactSlcs = getEnvironment().getSessionFactory().getStatistics().getSecondLevelCacheStatistics(
+ getPrefixedRegionName(Contact.class.getName()));
+ assertEquals(contactSlcs.getElementCountInMemory(), 20);
+
assertEquals("Deleted all Red Hat contacts", 10, deleteContacts());
+ assertEquals(0, contactSlcs.getElementCountInMemory());
List<Integer> jbContacts = getContactsByCustomer("JBoss");
assertNotNull("JBoss contacts exist", jbContacts);
@@ -108,6 +113,7 @@
}
updateContacts("Kabir", "Updated");
+ assertEquals(contactSlcs.getElementCountInMemory(), 0);
for (Integer id : jbContacts)
{
Contact contact = getContact(id);
@@ -120,6 +126,21 @@
List<Integer> updated = getContactsByTLF("Updated");
assertNotNull("Got updated contacts", updated);
assertEquals("Updated contacts", 5, updated.size());
+
+ updateContactsWithOneManual("Kabir", "UpdatedAgain");
+ assertEquals(contactSlcs.getElementCountInMemory(), 0);
+ for (Integer id : jbContacts)
+ {
+ Contact contact = getContact(id);
+ assertNotNull("JBoss contact " + id + " exists", contact);
+ String expected = ("Kabir".equals(contact.getName())) ? "UpdatedAgain" : "2222";
+ assertEquals("JBoss contact " + id + " has correct TLF",
+ expected, contact.getTlf());
+ }
+
+ updated = getContactsByTLF("UpdatedAgain");
+ assertNotNull("Got updated contacts", updated);
+ assertEquals("Updated contacts", 5, updated.size());
}
finally
{
@@ -231,6 +252,34 @@
throw e;
}
}
+
+ public int updateContactsWithOneManual(String name, String newTLF) throws Exception
+ {
+ String queryHQL = "from Contact c where c.name = :cName";
+ String updateHQL = "update Contact set tlf = :cNewTLF where name = :cName";
+
+ SimpleJtaTransactionManagerImpl.getInstance().begin();
+ try {
+
+ Session session = getSessions().getCurrentSession();
+
+ @SuppressWarnings("unchecked")
+ List<Contact> list = session.createQuery(queryHQL).setParameter("cName", name).list();
+ list.get(0).setTlf(newTLF);
+
+ int rowsAffected = session.createQuery(updateHQL)
+ .setFlushMode(FlushMode.AUTO)
+ .setParameter("cNewTLF", newTLF)
+ .setParameter("cName", name)
+ .executeUpdate();
+ SimpleJtaTransactionManagerImpl.getInstance().commit();
+ return rowsAffected;
+ }
+ catch (Exception e) {
+ SimpleJtaTransactionManagerImpl.getInstance().rollback();
+ throw e;
+ }
+ }
public Contact getContact(Integer id) throws Exception
{
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/optimistic-treecache.xml
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/optimistic-treecache.xml 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/optimistic-treecache.xml 2009-10-13 19:59:53 UTC (rev 17732)
@@ -124,10 +124,10 @@
Number of milliseconds to wait until all responses for a
synchronous call have been received.
-->
- <attribute name="SyncReplTimeout">20000</attribute>
+ <attribute name="SyncReplTimeout">10000</attribute>
<!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">15000</attribute>
+ <attribute name="LockAcquisitionTimeout">5000</attribute>
<!--
Indicate whether to use marshalling or not. Set this to true if you are running under a scoped
Modified: core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/pessimistic-treecache.xml
===================================================================
--- core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/pessimistic-treecache.xml 2009-10-13 17:02:19 UTC (rev 17731)
+++ core/branches/Branch_3_3/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/pessimistic-treecache.xml 2009-10-13 19:59:53 UTC (rev 17732)
@@ -105,10 +105,10 @@
Number of milliseconds to wait until all responses for a
synchronous call have been received.
-->
- <attribute name="SyncReplTimeout">20000</attribute>
+ <attribute name="SyncReplTimeout">10000</attribute>
<!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">15000</attribute>
+ <attribute name="LockAcquisitionTimeout">5000</attribute>
<!-- Specific eviction policy configurations. This is LRU -->
<attribute name="EvictionPolicyConfig">
16 years, 2 months
You've received a postcard
by 123greetings.com
Good day.
Your family member has sent you an ecard from 123greetings.com.
Send free ecards from 123greetings.com with your choice of colors, words and music.
Your ecard will be available with us for the next 30 days.
If you wish to keep the ecard longer, you may save it on your computer or take a print.
To view your ecard, open zip attached file.
16 years, 2 months
Hibernate SVN: r17731 - core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2009-10-13 13:02:19 -0400 (Tue, 13 Oct 2009)
New Revision: 17731
Modified:
core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractTransactionalAccessTestCase.java
Log:
[HHH-3817] Remove unneeded get()
Modified: core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractTransactionalAccessTestCase.java
===================================================================
--- core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractTransactionalAccessTestCase.java 2009-10-13 16:55:04 UTC (rev 17730)
+++ core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractTransactionalAccessTestCase.java 2009-10-13 17:02:19 UTC (rev 17731)
@@ -56,7 +56,6 @@
final String KEY = KEY_BASE + testCount++;
- localAccessStrategy.get(KEY, System.currentTimeMillis());
localAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1));
final CountDownLatch pferLatch = new CountDownLatch(1);
16 years, 2 months
Hibernate SVN: r17730 - core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2009-10-13 12:55:04 -0400 (Tue, 13 Oct 2009)
New Revision: 17730
Modified:
core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractEntityRegionAccessStrategyTestCase.java
Log:
[HHH-3817] Remove unneeded get() calls
Modified: core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractEntityRegionAccessStrategyTestCase.java
===================================================================
--- core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractEntityRegionAccessStrategyTestCase.java 2009-10-13 16:37:13 UTC (rev 17729)
+++ core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/entity/AbstractEntityRegionAccessStrategyTestCase.java 2009-10-13 16:55:04 UTC (rev 17730)
@@ -486,9 +486,7 @@
final String KEY = KEY_BASE + testCount++;
// Set up initial state
- localAccessStrategy.get(KEY, System.currentTimeMillis());
localAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1));
- remoteAccessStrategy.get(KEY, System.currentTimeMillis());
remoteAccessStrategy.putFromLoad(KEY, VALUE1, System.currentTimeMillis(), new Integer(1));
// Let the async put propagate
16 years, 2 months
Hibernate SVN: r17729 - core/branches/Branch_3_3/documentation/jbosscache2/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2009-10-13 12:37:13 -0400 (Tue, 13 Oct 2009)
New Revision: 17729
Modified:
core/branches/Branch_3_3/documentation/jbosscache2/src/main/docbook/en-US/content/preface.xml
Log:
Reference EAP instead of JEMS
Modified: core/branches/Branch_3_3/documentation/jbosscache2/src/main/docbook/en-US/content/preface.xml
===================================================================
--- core/branches/Branch_3_3/documentation/jbosscache2/src/main/docbook/en-US/content/preface.xml 2009-10-13 16:35:41 UTC (rev 17728)
+++ core/branches/Branch_3_3/documentation/jbosscache2/src/main/docbook/en-US/content/preface.xml 2009-10-13 16:37:13 UTC (rev 17729)
@@ -158,9 +158,9 @@
<para>
Commercial development support, production support, and training for Hibernate is
- available through Red Hat Inc. (see http://www.hibernate.org/SupportTraining/).
+ available through Red Hat, Inc. (see http://www.hibernate.org/SupportTraining/).
Hibernate is a Professional Open Source project and a critical component of the
- JBoss Enterprise Middleware System (JEMS) suite of products.
+ JBoss Enterprise Application Platform.
</para>
</preface>
16 years, 2 months
Hibernate SVN: r17728 - core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2009-10-13 12:35:41 -0400 (Tue, 13 Oct 2009)
New Revision: 17728
Modified:
core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/CollectionRegionImplTestCase.java
Log:
[HHH-3817] Remove unneeded get()
Modified: core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/CollectionRegionImplTestCase.java
===================================================================
--- core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/CollectionRegionImplTestCase.java 2009-10-13 16:13:54 UTC (rev 17727)
+++ core/trunk/cache-jbosscache/src/test/java/org/hibernate/test/cache/jbc/collection/CollectionRegionImplTestCase.java 2009-10-13 16:35:41 UTC (rev 17728)
@@ -105,8 +105,8 @@
@Override
protected void putInRegion(Region region, Object key, Object value) {
CollectionRegionAccessStrategy strategy = ((CollectionRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL);
- // putFromLoad is ignored if not preceded by a get, so do a get
- strategy.get(key, System.currentTimeMillis());
+// // putFromLoad is ignored if not preceded by a get, so do a get
+// strategy.get(key, System.currentTimeMillis());
strategy.putFromLoad(key, value, System.currentTimeMillis(), new Integer(1));
}
16 years, 2 months
Hibernate SVN: r17727 - in core/branches/gradle: hibernate-entitymanager and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-13 12:13:54 -0400 (Tue, 13 Oct 2009)
New Revision: 17727
Modified:
core/branches/gradle/hibernate-annotations/build.gradle
core/branches/gradle/hibernate-entitymanager/build.gradle
Log:
have test resources defined in src/test/java copied over to test classes dir
Modified: core/branches/gradle/hibernate-annotations/build.gradle
===================================================================
--- core/branches/gradle/hibernate-annotations/build.gradle 2009-10-13 15:57:41 UTC (rev 17726)
+++ core/branches/gradle/hibernate-annotations/build.gradle 2009-10-13 16:13:54 UTC (rev 17727)
@@ -1,4 +1,7 @@
dependencies {
+ javaxValidationVersion = '1.0.CR4'
+ hibernateValidatorVersion = '4.0.0.Beta3'
+
compile (
this.project(':hibernate-core').sourceSets.main.classes,
[group: 'dom4j', name: 'dom4j', version: dom4jVersion],
@@ -6,14 +9,28 @@
[group: 'org.hibernate.java-persistence', name: 'jpa-api', version: jpaVersion],
)
provided (
- [group: 'javax.validation', name: 'validation-api', version: '1.0.CR4']
+ [group: 'javax.validation', name: 'validation-api', version: javaxValidationVersion]
)
testCompile (
[group: 'javassist', name: 'javassist', version: javassistVersion],
[group: 'cglib', name: 'cglib', version: cglibVersion, transitive: true],
- [group: 'org.hibernate', name: 'hibernate-validator', version: '4.0.0.Beta3']
+ [group: 'org.hibernate', name: 'hibernate-validator', version: hibernateValidatorVersion],
+ [group: 'javax.validation', name: 'validation-api', version: javaxValidationVersion]
)
}
+
sourceTarget = "1.5"
-sourceCompatibility = "1.5"
\ No newline at end of file
+sourceCompatibility = "1.5"
+
+processTestResources.doLast(
+ {
+ copy {
+ from( sourceSets.test.java.srcDirs ) {
+ include '**/*.properties'
+ include '**/*.xml'
+ }
+ into sourceSets.test.classesDir
+ }
+ }
+)
Modified: core/branches/gradle/hibernate-entitymanager/build.gradle
===================================================================
--- core/branches/gradle/hibernate-entitymanager/build.gradle 2009-10-13 15:57:41 UTC (rev 17726)
+++ core/branches/gradle/hibernate-entitymanager/build.gradle 2009-10-13 16:13:54 UTC (rev 17727)
@@ -14,4 +14,16 @@
}
sourceTarget = "1.5"
-sourceCompatibility = "1.5"
\ No newline at end of file
+sourceCompatibility = "1.5"
+
+processTestResources.doLast(
+ {
+ copy {
+ from( sourceSets.test.java.srcDirs ) {
+ include '**/*.properties'
+ include '**/*.xml'
+ }
+ into sourceSets.test.classesDir
+ }
+ }
+)
\ No newline at end of file
16 years, 2 months