[hibernate-commits] Hibernate SVN: r17738 - in annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id: sequences and 1 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Wed Oct 14 01:37:23 EDT 2009
Author: stliu
Date: 2009-10-14 01:37:23 -0400 (Wed, 14 Oct 2009)
New Revision: 17738
Added:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/EnumIdTest.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdClassTest.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdTest.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Ball.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Computer.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Department.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Dog.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FirTree.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Footballer.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Furniture.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Home.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Location.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Monkey.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Phone.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Planet.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Shoe.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Store.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tower.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tree.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/package-info.java
Modified:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Department.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/IdTest.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Phone.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Shoe.java
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Store.java
Log:
JBPAPP-1061 HHH-4397 Tests using sequences are run on databases which doesn't supports sequences
Modified: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Department.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Department.java 2009-10-14 05:32:56 UTC (rev 17737)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Department.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -2,9 +2,9 @@
package org.hibernate.test.annotations.id;
import java.io.Serializable;
+
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
@@ -17,11 +17,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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/IdTest.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/IdTest.java 2009-10-14 05:32:56 UTC (rev 17737)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/IdTest.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -10,7 +10,6 @@
* @author Emmanuel Bernard
*/
public class IdTest extends TestCase {
- //FIXME split Sequence and Id tests to explicit the run failure on Oracle etc
public IdTest(String x) {
super( x );
Modified: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Phone.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Phone.java 2009-10-14 05:32:56 UTC (rev 17737)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Phone.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Shoe.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Shoe.java 2009-10-14 05:32:56 UTC (rev 17737)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Shoe.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -2,9 +2,9 @@
package org.hibernate.test.annotations.id;
import java.io.Serializable;
+
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
@@ -17,7 +17,7 @@
private Long id;
@Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN")
+ @GeneratedValue
public Long getId() {
return id;
}
Modified: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Store.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Store.java 2009-10-14 05:32:56 UTC (rev 17737)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/Store.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -2,9 +2,9 @@
package org.hibernate.test.annotations.id;
import java.io.Serializable;
+
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
@@ -13,15 +13,11 @@
* @author Emmanuel Bernard
*/
@Entity
- at javax.persistence.SequenceGenerator(
- name = "SEQ_STORE",
- sequenceName = "my_sequence"
-)
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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/EnumIdTest.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/EnumIdTest.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/EnumIdTest.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -0,0 +1,64 @@
+//$Id: EnumIdTest.java 14785 2008-06-19 10:44:33Z hardy.ferentschik $
+package org.hibernate.test.annotations.id.sequences;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.sequences.entities.Planet;
+import org.hibernate.test.annotations.id.sequences.entities.PlanetCheatSheet;
+
+
+
+/**
+ * Tests for enum type as id.
+ *
+ * @author Hardy Ferentschik
+ * @see ANN-744
+ */
+ at SuppressWarnings("unchecked")
+public class EnumIdTest extends TestCase {
+
+ private Log log = LogFactory.getLog(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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdClassTest.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdClassTest.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdClassTest.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -0,0 +1,39 @@
+//$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.sequences.entities.Location;
+import org.hibernate.test.annotations.id.sequences.entities.Tower;
+
+
+/**
+ * @author Emmanuel Bernard
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdTest.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdTest.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/IdTest.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/JoinColumnOverrideTest.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -0,0 +1,66 @@
+//$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.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.sequences.entities.Bunny;
+import org.hibernate.test.annotations.id.sequences.entities.PointyTooth;
+import org.hibernate.test.annotations.id.sequences.entities.TwinkleToes;
+
+
+
+/**
+ * Tests for JIRA issue ANN-748.
+ *
+ * @author Hardy Ferentschik
+ */
+ at SuppressWarnings("unchecked")
+public class JoinColumnOverrideTest extends TestCase {
+
+ private Log log = LogFactory.getLog(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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/UUIDGenerator.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Ball.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Ball.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Ball.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at TableGenerator(name = "EMP_GEN", table = "GENERATOR_TABLE", pkColumnName = "pkey",
+ valueColumnName = "hi", pkColumnValue = "Ball", allocationSize = 10)
+ at Entity
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/BreakDance.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Bunny.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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 at osintegrators.com
+ */
+ at Entity
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Computer.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Computer.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Computer.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Department.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Department.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Department.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at Entity
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Dog.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Dog.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Dog.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at Entity
+ at Table(name = "tbl_dog")
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FirTree.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FirTree.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FirTree.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at Entity
+public class FirTree extends Tree {
+}
Added: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Footballer.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Footballer.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Footballer.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at Entity
+ at IdClass(FootballerPk.class)
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/FootballerPk.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at Embeddable
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Furniture.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Furniture.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Furniture.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/GoalKeeper.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at Entity
+public class GoalKeeper extends Footballer {
+ public GoalKeeper() {
+ }
+
+ public GoalKeeper(String firstname, String lastname, String club) {
+ super( firstname, lastname, club );
+ }
+}
Added: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Home.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Home.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Home.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Location.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Location.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Location.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/MilitaryBuilding.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at MappedSuperclass
+ at IdClass(Location.class)
+public class MilitaryBuilding {
+ @Id
+ public double longitude;
+ @Id
+ public double latitude;
+}
Added: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Monkey.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Monkey.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Monkey.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Phone.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Phone.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Phone.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Planet.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Planet.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Planet.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PlanetCheatSheet.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/PointyTooth.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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 at osintegrators.com
+ */
+ at Entity
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Shoe.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Shoe.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Shoe.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at Entity
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/SoundSystem.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Store.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Store.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Store.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at Entity
+ at javax.persistence.SequenceGenerator(
+ name = "SEQ_STORE",
+ sequenceName = "my_sequence"
+)
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tower.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tower.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tower.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at Entity
+ at AttributeOverride(name = "longitude", column = @Column(name = "fld_longitude"))
+public class Tower extends MilitaryBuilding {
+}
Added: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tree.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tree.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/Tree.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/entities/TwinkleToes.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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 at osintegrators.com
+ */
+ at Entity
+ at 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_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/package-info.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/package-info.java (rev 0)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/id/sequences/package-info.java 2009-10-14 05:37:23 UTC (rev 17738)
@@ -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
+ */
+ at org.hibernate.annotations.GenericGenerator(name = "system-uuid", strategy = "uuid")
+ at org.hibernate.annotations.GenericGenerators(
+ @org.hibernate.annotations.GenericGenerator(name = "system-uuid-2", strategy = "uuid")
+)
+package org.hibernate.test.annotations.id.sequences;
+
More information about the hibernate-commits
mailing list