HHH-4397 Split test involving database specific features (like sequence / identity)
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17734 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
bca8c96204
commit
6ddd9690a5
|
@ -3,9 +3,7 @@ package org.hibernate.test.annotations.id;
|
|||
|
||||
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 @@ import org.hibernate.test.annotations.id.entities.Tree;
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@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();
|
||||
|
|
|
@ -18,11 +18,7 @@ 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"
|
||||
)
|
||||
@GeneratedValue
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.hibernate.test.annotations.id.entities;
|
|||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
|
@ -14,11 +13,7 @@ public class Phone {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class Shoe implements Serializable {
|
|||
private Long id;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN")
|
||||
@GeneratedValue
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -13,16 +13,12 @@ import javax.persistence.Id;
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@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;
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
}
|
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
|
@ -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" };
|
||||
}
|
||||
|
||||
}
|
|
@ -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[] {};
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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@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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
}
|
|
@ -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
|
||||
@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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
@IdClass(Location.class)
|
||||
public class MilitaryBuilding {
|
||||
@Id
|
||||
public double longitude;
|
||||
@Id
|
||||
public double latitude;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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@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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
@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;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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@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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
*/
|
||||
@org.hibernate.annotations.GenericGenerator(name = "system-uuid", strategy = "uuid")
|
||||
@org.hibernate.annotations.GenericGenerators(
|
||||
@org.hibernate.annotations.GenericGenerator(name = "system-uuid-2", strategy = "uuid")
|
||||
)
|
||||
package org.hibernate.test.annotations.id.sequences;
|
||||
|
Loading…
Reference in New Issue