Hibernate SVN: r14760 - in annotations/trunk/src/test/org/hibernate/test/annotations/id: entities and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-11 03:33:15 -0400 (Wed, 11 Jun 2008)
New Revision: 14760
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/id/UUIDGenerator.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Ball.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/BreakDance.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Bunny.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Computer.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Department.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Dog.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/FirTree.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Footballer.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/FootballerPk.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Furniture.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/GoalKeeper.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Home.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Location.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/MilitaryBuilding.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Monkey.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Phone.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PointyTooth.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Shoe.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/SoundSystem.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Store.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Tower.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Tree.java
Removed:
annotations/trunk/src/test/org/hibernate/test/annotations/id/Ball.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/BreakDance.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Computer.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Department.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Dog.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/FirTree.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Footballer.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/FootballerPk.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Furniture.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/GoalKeeper.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Home.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Location.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/MilitaryBuilding.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Monkey.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Phone.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Shoe.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/SoundSystem.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Store.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Tower.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/Tree.java
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/id/IdClassTest.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/IdTest.java
Log:
ANN-748:
- Added test case for
- Seperated test classes from test entities to make things a little easier to find
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Ball.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Ball.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Ball.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,34 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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
-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;
- }
-
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/BreakDance.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/BreakDance.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/BreakDance.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,27 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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;
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Computer.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Computer.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Computer.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,34 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Department.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Department.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Department.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,32 +0,0 @@
-//$Id$
-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;
-
-/**
- * Sample of method generator
- *
- * @author Emmanuel Bernard
- */
-@Entity
-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;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Dog.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Dog.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Dog.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,42 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/FirTree.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/FirTree.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/FirTree.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,11 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-import javax.persistence.Entity;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-public class FirTree extends Tree {
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Footballer.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Footballer.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Footballer.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,73 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-import javax.persistence.DiscriminatorColumn;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-(a)IdClass(FootballerPk.class)
-@DiscriminatorColumn(name = "bibi")
-public class Footballer {
- private String firstname;
- private String lastname;
- private String club;
-
- public Footballer() {
- }
-
- public Footballer(String firstname, String lastname, String club) {
- this.firstname = firstname;
- this.lastname = lastname;
- this.club = club;
- }
-
- public boolean equals(Object o) {
- if ( this == o ) return true;
- if ( !( o instanceof Footballer ) ) return false;
-
- final Footballer footballer = (Footballer) o;
-
- if ( !firstname.equals( footballer.firstname ) ) return false;
- if ( !lastname.equals( footballer.lastname ) ) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = firstname.hashCode();
- result = 29 * result + lastname.hashCode();
- return result;
- }
-
- @Id
- public String getFirstname() {
- return firstname;
- }
-
- public void setFirstname(String firstname) {
- this.firstname = firstname;
- }
-
- @Id
- public String getLastname() {
- return lastname;
- }
-
- public void setLastname(String lastname) {
- this.lastname = lastname;
- }
-
- public String getClub() {
- return club;
- }
-
- public void setClub(String club) {
- this.club = club;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/FootballerPk.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/FootballerPk.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/FootballerPk.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,61 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-import java.io.Serializable;
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
-
-/**
- * @author Emmanuel Bernard
- */
-@Embeddable
-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;
- }
-
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Furniture.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Furniture.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Furniture.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,33 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/GoalKeeper.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/GoalKeeper.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/GoalKeeper.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,17 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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 );
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Home.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Home.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Home.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,26 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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;
- }
-}
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/id/IdClassTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/IdClassTest.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/IdClassTest.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -4,6 +4,8 @@
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
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/id/IdTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/IdTest.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/IdTest.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -3,53 +3,79 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.mapping.Column;
import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.entities.Ball;
+import org.hibernate.test.annotations.id.entities.BreakDance;
+import org.hibernate.test.annotations.id.entities.Bunny;
+import org.hibernate.test.annotations.id.entities.Computer;
+import org.hibernate.test.annotations.id.entities.Department;
+import org.hibernate.test.annotations.id.entities.Dog;
+import org.hibernate.test.annotations.id.entities.FirTree;
+import org.hibernate.test.annotations.id.entities.Footballer;
+import org.hibernate.test.annotations.id.entities.FootballerPk;
+import org.hibernate.test.annotations.id.entities.Furniture;
+import org.hibernate.test.annotations.id.entities.GoalKeeper;
+import org.hibernate.test.annotations.id.entities.Home;
+import org.hibernate.test.annotations.id.entities.Monkey;
+import org.hibernate.test.annotations.id.entities.Phone;
+import org.hibernate.test.annotations.id.entities.PointyTooth;
+import org.hibernate.test.annotations.id.entities.Shoe;
+import org.hibernate.test.annotations.id.entities.SoundSystem;
+import org.hibernate.test.annotations.id.entities.Store;
+import org.hibernate.test.annotations.id.entities.Tree;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Emmanuel Bernard
*/
+@SuppressWarnings("unchecked")
public class IdTest extends TestCase {
- //FIXME split Sequence and Id tests to explicit the run failure on Oracle etc
+ // FIXME split Sequence and Id tests to explicit the run failure on Oracle etc
+ private Logger log = LoggerFactory.getLogger(IdTest.class);
+
public IdTest(String x) {
- super( x );
+ super(x);
}
public void testGenericGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
SoundSystem system = new SoundSystem();
- system.setBrand( "Genelec" );
- system.setModel( "T234" );
+ system.setBrand("Genelec");
+ system.setModel("T234");
Furniture fur = new Furniture();
- s.persist( system );
- s.persist( fur );
+ 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 );
+ 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
+ * 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.persist(monkey);
s.flush();
assertNotNull(monkey.getId());
tx.rollback();
@@ -63,20 +89,21 @@
Ball b = new Ball();
Dog d = new Dog();
Computer c = new Computer();
- s.persist( b );
- s.persist( d );
- s.persist( c );
+ 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() );
+ 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 ) ) );
+ 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();
}
@@ -85,14 +112,14 @@
Session s = openSession();
Transaction tx = s.beginTransaction();
Shoe b = new Shoe();
- s.persist( b );
+ s.persist(b);
tx.commit();
s.close();
- assertNotNull( b.getId() );
+ assertNotNull(b.getId());
s = openSession();
tx = s.beginTransaction();
- s.delete( s.get( Shoe.class, b.getId() ) );
+ s.delete(s.get(Shoe.class, b.getId()));
tx.commit();
s.close();
}
@@ -101,14 +128,14 @@
Session s = openSession();
Transaction tx = s.beginTransaction();
Store b = new Store();
- s.persist( b );
+ s.persist(b);
tx.commit();
s.close();
- assertNotNull( b.getId() );
+ assertNotNull(b.getId());
s = openSession();
tx = s.beginTransaction();
- s.delete( s.get( Store.class, b.getId() ) );
+ s.delete(s.get(Store.class, b.getId()));
tx.commit();
s.close();
}
@@ -117,14 +144,14 @@
Session s = openSession();
Transaction tx = s.beginTransaction();
Department b = new Department();
- s.persist( b );
+ s.persist(b);
tx.commit();
s.close();
- assertNotNull( b.getId() );
+ assertNotNull(b.getId());
s = openSession();
tx = s.beginTransaction();
- s.delete( s.get( Department.class, b.getId() ) );
+ s.delete(s.get(Department.class, b.getId()));
tx.commit();
s.close();
}
@@ -135,16 +162,16 @@
s = openSession();
tx = s.beginTransaction();
Home h = new Home();
- s.persist( h );
+ s.persist(h);
tx.commit();
s.close();
- assertNotNull( h.getId() );
+ 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 );
+ Home reloadedHome = (Home) s.get(Home.class, h.getId());
+ assertEquals(h.getId(), reloadedHome.getId());
+ s.delete(reloadedHome);
tx.commit();
s.close();
}
@@ -155,16 +182,16 @@
s = openSession();
tx = s.beginTransaction();
Home h = new Home();
- s.persist( h );
+ s.persist(h);
tx.commit();
s.close();
- assertNotNull( h.getId() );
+ 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 );
+ Home reloadedHome = (Home) s.get(Home.class, h.getId());
+ assertEquals(h.getId(), reloadedHome.getId());
+ s.delete(reloadedHome);
tx.commit();
s.close();
}
@@ -175,13 +202,13 @@
s = openSession();
tx = s.beginTransaction();
FirTree chrismasTree = new FirTree();
- s.persist( chrismasTree );
+ s.persist(chrismasTree);
tx.commit();
s.clear();
tx = s.beginTransaction();
- chrismasTree = (FirTree) s.get( FirTree.class, chrismasTree.getId() );
- assertNotNull( chrismasTree );
- s.delete( chrismasTree );
+ chrismasTree = (FirTree) s.get(FirTree.class, chrismasTree.getId());
+ assertNotNull(chrismasTree);
+ s.delete(chrismasTree);
tx.commit();
s.close();
}
@@ -191,54 +218,55 @@
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 );
+ 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
+ // 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() );
+ 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
+ // reattach by merge
tx = s.beginTransaction();
- fb.setClub( "Bimbo FC" );
- s.merge( fb );
+ fb.setClub("Bimbo FC");
+ s.merge(fb);
tx.commit();
- //reattach by saveOrUpdate
+ // reattach by saveOrUpdate
tx = s.beginTransaction();
- fb.setClub( "Bimbo FC SA" );
- s.saveOrUpdate( fb );
+ fb.setClub("Bimbo FC SA");
+ s.saveOrUpdate(fb);
tx.commit();
- //clean up
+ // 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 );
+ 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() );
+ Column idCol = (Column) getCfg().getClassMapping(Ball.class.getName())
+ .getIdentifierProperty().getValue().getColumnIterator().next();
+ assertEquals("ball_id", idCol.getName());
}
public void testLowAllocationSize() throws Exception {
@@ -248,57 +276,77 @@
tx = s.beginTransaction();
int size = 4;
BreakDance[] bds = new BreakDance[size];
- for (int i = 0 ; i < size ; i++) {
+ for (int i = 0; i < size; i++) {
bds[i] = new BreakDance();
- s.persist( bds[i] );
+ s.persist(bds[i]);
}
s.flush();
- for (int i = 0 ; i < size ; i++) {
- assertEquals(i + 1, bds[i].id.intValue() );
+ for (int i = 0; i < size; i++) {
+ assertEquals(i + 1, bds[i].id.intValue());
}
tx.rollback();
s.close();
}
/**
+ * See JIRA bug ANN-748.
+ */
+ public void testBlownPrecision() throws Exception {
+
+ try {
+ AnnotationConfiguration config = new AnnotationConfiguration();
+ config.addAnnotatedClass(Bunny.class);
+ config.addAnnotatedClass(PointyTooth.class);
+ config.buildSessionFactory();
+ String[] schema = config
+ .generateSchemaCreationScript(new SQLServerDialect());
+ for (String s : schema) {
+ log.debug(s);
+ }
+ String expectedMappingTableSql = "create table PointyTooth (id numeric(128,0) not null, " +
+ "bunny_id numeric(128,0) null, primary key (id))";
+ assertEquals("Wrong SQL", expectedMappingTableSql, schema[1]);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+
+// Session s = openSession();
+// Transaction tx = s.beginTransaction();
+// Bunny bunny = new Bunny();
+// PointyTooth tooth = new PointyTooth();
+// Set<PointyTooth> teeth = new HashSet<PointyTooth>();
+// teeth.add(tooth);
+// bunny.setTeeth(teeth);
+// tooth.setBunny(bunny);
+// s.persist(bunny);
+// s.flush();
+// tx.rollback();
+// s.close();
+ }
+
+ /**
* @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
- };
+ 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, Bunny.class, PointyTooth.class };
}
/**
* @see org.hibernate.test.annotations.TestCase#getAnnotatedPackages()
*/
protected String[] getAnnotatedPackages() {
- return new String[]{
- "org.hibernate.test.annotations",
- "org.hibernate.test.annotations.id"
- };
+ 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"
- };
+ return new String[] { "org/hibernate/test/annotations/orm.xml" };
}
}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Location.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Location.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Location.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,34 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-import java.io.Serializable;
-
-/**
- * @author Emmanuel Bernard
- */
-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;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/MilitaryBuilding.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/MilitaryBuilding.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/MilitaryBuilding.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,18 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.MappedSuperclass;
-
-/**
- * @author Emmanuel Bernard
- */
-@MappedSuperclass
-(a)IdClass(Location.class)
-public class MilitaryBuilding {
- @Id
- public double longitude;
- @Id
- public double latitude;
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Monkey.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Monkey.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Monkey.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,24 +0,0 @@
-//$
-package org.hibernate.test.annotations.id;
-
-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;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Phone.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Phone.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Phone.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,29 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Shoe.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Shoe.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Shoe.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,28 +0,0 @@
-//$Id$
-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;
-
-/**
- * sample of Sequance generator
- *
- * @author Emmanuel Bernard
- */
-@Entity
-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;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/SoundSystem.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/SoundSystem.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/SoundSystem.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,42 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Store.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Store.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Store.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,32 +0,0 @@
-//$Id$
-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;
-
-/**
- * Sample of class generator
- *
- * @author Emmanuel Bernard
- */
-@Entity
-(a)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")
- public Long getId() {
- return id;
- }
-
- public void setId(Long long1) {
- id = long1;
- }
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Tower.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Tower.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Tower.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,14 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-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 {
-}
Deleted: annotations/trunk/src/test/org/hibernate/test/annotations/id/Tree.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/Tree.java 2008-06-10 14:14:15 UTC (rev 14759)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/Tree.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -1,24 +0,0 @@
-//$Id$
-package org.hibernate.test.annotations.id;
-
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.MappedSuperclass;
-
-/**
- * @author Emmanuel Bernard
- */
-@MappedSuperclass
-public class Tree {
- private Integer id;
-
- @Id
- @GeneratedValue
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-}
Added: annotations/trunk/src/test/org/hibernate/test/annotations/id/UUIDGenerator.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/UUIDGenerator.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/UUIDGenerator.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,34 @@
+package org.hibernate.test.annotations.id;
+
+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;
+ }
+
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/id/UUIDGenerator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Ball.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Ball.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Ball.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Ball.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,35 @@
+//$Id$
+package org.hibernate.test.annotations.id.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;
+ }
+
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/BreakDance.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/BreakDance.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/BreakDance.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/BreakDance.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,27 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.TableGenerator;
+import javax.persistence.GenerationType;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class BreakDance {
+ @Id
+ @GeneratedValue(generator = "memencoIdGen", strategy = GenerationType.TABLE)
+ @TableGenerator(
+ name = "memencoIdGen",
+ table = "hi_id_key",
+ pkColumnName = "id_key",
+ valueColumnName = "next_hi",
+ pkColumnValue = "issue",
+ allocationSize = 1
+ )
+ public Integer id;
+ public String name;
+}
Added: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Bunny.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Bunny.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Bunny.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,39 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * Blown precision on related entity when @JoinColumn is used.
+ *
+ * @see ANN-748
+ * @author Andrew C. Oliver andyspam(a)osintegrators.com
+ */
+@Entity
+@SuppressWarnings("serial")
+public class Bunny implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @Column(name = "id", precision = 128, scale = 0)
+ private BigInteger id;
+
+ @OneToMany(mappedBy = "bunny", cascade = { CascadeType.PERSIST })
+ Set<PointyTooth> teeth;
+
+ public void setTeeth(Set<PointyTooth> teeth) {
+ this.teeth = teeth;
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Bunny.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Computer.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Computer.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Computer.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Computer.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,34 @@
+//$Id$
+package org.hibernate.test.annotations.id.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;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Department.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Department.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Department.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Department.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,33 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * 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;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Dog.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Dog.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Dog.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Dog.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,42 @@
+//$Id$
+package org.hibernate.test.annotations.id.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;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/FirTree.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/FirTree.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/FirTree.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/FirTree.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,11 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class FirTree extends Tree {
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Footballer.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Footballer.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Footballer.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Footballer.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,73 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+(a)IdClass(FootballerPk.class)
+@DiscriminatorColumn(name = "bibi")
+public class Footballer {
+ private String firstname;
+ private String lastname;
+ private String club;
+
+ public Footballer() {
+ }
+
+ public Footballer(String firstname, String lastname, String club) {
+ this.firstname = firstname;
+ this.lastname = lastname;
+ this.club = club;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) return true;
+ if ( !( o instanceof Footballer ) ) return false;
+
+ final Footballer footballer = (Footballer) o;
+
+ if ( !firstname.equals( footballer.firstname ) ) return false;
+ if ( !lastname.equals( footballer.lastname ) ) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = firstname.hashCode();
+ result = 29 * result + lastname.hashCode();
+ return result;
+ }
+
+ @Id
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ @Id
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public String getClub() {
+ return club;
+ }
+
+ public void setClub(String club) {
+ this.club = club;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/FootballerPk.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/FootballerPk.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/FootballerPk.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/FootballerPk.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,62 @@
+//$Id$
+package org.hibernate.test.annotations.id.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;
+ }
+
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Furniture.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Furniture.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Furniture.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Furniture.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,33 @@
+//$Id$
+package org.hibernate.test.annotations.id.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;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/GoalKeeper.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/GoalKeeper.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/GoalKeeper.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/GoalKeeper.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,17 @@
+//$Id$
+package org.hibernate.test.annotations.id.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 );
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Home.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Home.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Home.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Home.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,26 @@
+//$Id$
+package org.hibernate.test.annotations.id.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;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Location.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Location.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Location.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Location.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,35 @@
+//$Id$
+package org.hibernate.test.annotations.id.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;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/MilitaryBuilding.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/MilitaryBuilding.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/MilitaryBuilding.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/MilitaryBuilding.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,18 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.MappedSuperclass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+(a)IdClass(Location.class)
+public class MilitaryBuilding {
+ @Id
+ public double longitude;
+ @Id
+ public double latitude;
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Monkey.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Monkey.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Monkey.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Monkey.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,24 @@
+//$
+package org.hibernate.test.annotations.id.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;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Phone.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Phone.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Phone.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Phone.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,29 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity()
+public class Phone {
+ private Integer id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Phone_Gen")
+ @javax.persistence.SequenceGenerator(
+ name = "Phone_Gen",
+ sequenceName = "phone_seq"
+ )
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Added: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PointyTooth.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PointyTooth.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PointyTooth.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,41 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * Blown precision on related entity when @JoinColumn is used.
+ * Does not cause an issue on HyperSonic, but replicates nicely on PGSQL.
+ *
+ * @see ANN-748
+ * @author Andrew C. Oliver andyspam(a)osintegrators.com
+ */
+@Entity
+@SuppressWarnings("serial")
+public class PointyTooth implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "java5_uuid")
+ @GenericGenerator(name = "java5_uuid", strategy = "org.hibernate.test.annotations.id.UUIDGenerator")
+ @Column(name = "id", precision = 128, scale = 0)
+ private BigInteger id;
+
+ @ManyToOne
+ // comment out the below line and the test will pass
+ //@JoinColumn(name = "bugs_bunny_id")
+ Bunny bunny;
+
+ public void setBunny(Bunny bunny) {
+ this.bunny = bunny;
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PointyTooth.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Shoe.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Shoe.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Shoe.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Shoe.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,29 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * 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;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/SoundSystem.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/SoundSystem.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/SoundSystem.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/SoundSystem.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,42 @@
+//$Id$
+package org.hibernate.test.annotations.id.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;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Store.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Store.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Store.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Store.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,33 @@
+//$Id$
+package org.hibernate.test.annotations.id.entities;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * Sample of class generator
+ *
+ * @author Emmanuel Bernard
+ */
+@Entity
+(a)javax.persistence.SequenceGenerator(
+ name = "SEQ_STORE",
+ sequenceName = "my_sequence"
+)
+@SuppressWarnings("serial")
+public class Store implements Serializable {
+ private Long id;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long long1) {
+ id = long1;
+ }
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Tower.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Tower.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Tower.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Tower.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,14 @@
+//$Id$
+package org.hibernate.test.annotations.id.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 {
+}
Copied: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Tree.java (from rev 14758, annotations/trunk/src/test/org/hibernate/test/annotations/id/Tree.java)
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Tree.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Tree.java 2008-06-11 07:33:15 UTC (rev 14760)
@@ -0,0 +1,24 @@
+//$Id$
+package org.hibernate.test.annotations.id.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;
+ }
+}
16 years, 6 months
Hibernate SVN: r14759 - in annotations/trunk/src: java/org/hibernate/cfg/annotations/reflection and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-10 10:14:15 -0400 (Tue, 10 Jun 2008)
New Revision: 14759
Modified:
annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java
annotations/trunk/src/test/log4j.properties
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java
Log:
ANN-742:
* Fixed bug in OneToOneSecondPass where the mapped by side of the one to one association also attempted to create the PK and FK
* little code cleanup
Modified: annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2008-06-10 13:48:38 UTC (rev 14758)
+++ annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2008-06-10 14:14:15 UTC (rev 14759)
@@ -215,7 +215,16 @@
if ( !BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName );
}
- //dirty dupe of EntityBinder.bindSecondaryTable
+ /**
+ * Builds the <code>Join</code> instance for the mapped by side of a <i>OneToOne</i> association using
+ * a join tables.
+ * <p>
+ * Note:<br/>
+ * <ul>
+ * <li>From the mappedBy side we should not create the PK nor the FK, this is handled from the other side.</li>
+ * <li>This method is a dirty dupe of EntityBinder.bindSecondaryTable</i>.
+ * </p>
+ */
private Join buildJoinFromMappedBySide(PersistentClass persistentClass, Property otherSideProperty, Join originalJoin) {
Join join = new Join();
join.setPersistentClass( persistentClass );
@@ -247,9 +256,6 @@
copy.setDefaultValue( column.getDefaultValue() );
key.addColumn( copy );
}
- //from the mappedBy side we should not create the PK nor the FK, this is handled from te other side
- //join.createPrimaryKey();
- //join.createForeignKey();
persistentClass.addJoin( join );
return join;
}
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java 2008-06-10 13:48:38 UTC (rev 14758)
+++ annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java 2008-06-10 14:14:15 UTC (rev 14759)
@@ -103,6 +103,7 @@
* @author Davide Marchignoli
* @author Emmanuel Bernard
*/
+@SuppressWarnings("unchecked")
public class EJB3OverridenAnnotationReader implements AnnotationReader {
private Logger log = LoggerFactory.getLogger( EJB3OverridenAnnotationReader.class );
private static final Map<Class, String> annotationToXml;
Modified: annotations/trunk/src/test/log4j.properties
===================================================================
--- annotations/trunk/src/test/log4j.properties 2008-06-10 13:48:38 UTC (rev 14758)
+++ annotations/trunk/src/test/log4j.properties 2008-06-10 14:14:15 UTC (rev 14759)
@@ -21,7 +21,7 @@
log4j.rootLogger=warn, stdout
-log4j.logger.org.hibernate=info
+log4j.logger.org.hibernate=debug
### log just the SQL
@@ -30,13 +30,13 @@
#log4j.logger.org.hibernate.engine.CascadingAction=debug
### log JDBC bind parameters ###
-#log4j.logger.org.hibernate.type=debug
+log4j.logger.org.hibernate.type=debug
### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug
### log cache activity ###
-#log4j.logger.org.hibernate.cache=debug
+log4j.logger.org.hibernate.cache=debug
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java 2008-06-10 13:48:38 UTC (rev 14758)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java 2008-06-10 14:14:15 UTC (rev 14759)
@@ -3,10 +3,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
import javax.persistence.OneToOne;
-import javax.persistence.Transient;
@Entity
public class Address {
@@ -15,7 +12,6 @@
private long id;
@OneToOne(mappedBy = "address")
-
private Person person;
public long getId() {
16 years, 6 months
Hibernate SVN: r14758 - in annotations/trunk/src: test/org/hibernate/test/annotations/onetoone/primarykey and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-06-10 09:48:38 -0400 (Tue, 10 Jun 2008)
New Revision: 14758
Modified:
annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java
Log:
ANN-742 mappedBy side should not generate the PF and FK: already done form the other side
Modified: annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2008-06-09 22:36:38 UTC (rev 14757)
+++ annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2008-06-10 13:48:38 UTC (rev 14758)
@@ -73,7 +73,7 @@
else {
referencedEntityName = targetEntity.getName();
}
- value.setReferencedEntityName( referencedEntityName );
+ value.setReferencedEntityName( referencedEntityName );
AnnotationBinder.defineFetchingStrategy( value, inferredData.getProperty() );
//value.setFetchMode( fetchMode );
value.setCascadeDeleteEnabled( cascadeOnDelete );
@@ -153,7 +153,7 @@
}
if ( otherSideJoin != null ) {
//@OneToOne @JoinTable
- Join mappedByJoin = buildJoin(
+ Join mappedByJoin = buildJoinFromMappedBySide(
(PersistentClass) persistentClasses.get( ownerEntity ), otherSideProperty, otherSideJoin
);
ManyToOne manyToOne = new ManyToOne( mappedByJoin.getTable() );
@@ -216,7 +216,7 @@
}
//dirty dupe of EntityBinder.bindSecondaryTable
- private Join buildJoin(PersistentClass persistentClass, Property otherSideProperty, Join originalJoin) {
+ private Join buildJoinFromMappedBySide(PersistentClass persistentClass, Property otherSideProperty, Join originalJoin) {
Join join = new Join();
join.setPersistentClass( persistentClass );
@@ -247,8 +247,9 @@
copy.setDefaultValue( column.getDefaultValue() );
key.addColumn( copy );
}
- join.createPrimaryKey();
- join.createForeignKey();
+ //from the mappedBy side we should not create the PK nor the FK, this is handled from te other side
+ //join.createPrimaryKey();
+ //join.createForeignKey();
persistentClass.addJoin( join );
return join;
}
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java 2008-06-09 22:36:38 UTC (rev 14757)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java 2008-06-10 13:48:38 UTC (rev 14758)
@@ -30,7 +30,7 @@
log.debug(s);
}
String expectedMappingTableSql = "create table personAddress (address_id numeric(19,0) null, " +
- "person_id numeric(19,0) not null, primary key (address_id))";
+ "person_id numeric(19,0) not null, primary key (person_id))";
assertEquals("Wrong SQL", expectedMappingTableSql, schema[2]);
} catch (Exception e) {
fail(e.getMessage());
16 years, 6 months
Hibernate SVN: r14757 - core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-06-09 18:36:38 -0400 (Mon, 09 Jun 2008)
New Revision: 14757
Modified:
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java
Log:
[HHH-3340] Don't fail if cache TM != discovered TM
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java 2008-06-09 22:27:40 UTC (rev 14756)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java 2008-06-09 22:36:38 UTC (rev 14757)
@@ -216,8 +216,8 @@
if (!safeEquals(tm, cacheTm)) {
if (cache.getCacheStatus() != CacheStatus.INSTANTIATED
&& cache.getCacheStatus() != CacheStatus.DESTROYED) {
- throw new CacheException("JBoss Cache is already started " + "with a transaction manager ("
- + cacheTm + ") that doesn't match our own (" + tm + ")");
+ log.debug("JBoss Cache is already started with a transaction manager ("
+ + cacheTm + ") that is not equal to our own (" + tm + ")");
} else {
// Configure the cache to use our TM
cacheConfig.getRuntimeConfig().setTransactionManager(tm);
16 years, 6 months
Hibernate SVN: r14756 - core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-06-09 18:27:40 -0400 (Mon, 09 Jun 2008)
New Revision: 14756
Modified:
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/MultiplexingCacheInstanceManager.java
Log:
[HHH-3340] Don't fail if cache TM != discovered TM
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/MultiplexingCacheInstanceManager.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/MultiplexingCacheInstanceManager.java 2008-06-09 16:58:31 UTC (rev 14755)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/MultiplexingCacheInstanceManager.java 2008-06-09 22:27:40 UTC (rev 14756)
@@ -411,10 +411,12 @@
if (cache.getCacheStatus() != CacheStatus.INSTANTIATED) {
// We can't change the TM on a running cache; just check
// if the cache has no TM and we're OK with that
- if (!allowNull || cacheTm != null) {
- throw new CacheException("JBoss Cache is already started " + "with a transaction manager ("
- + cacheTm + ") that doesn't match our own (" + tm + ")");
- }
+ if (!allowNull && cacheTm == null) {
+ throw new CacheException("JBoss Cache is already started with no transaction manager configured");
+ } else {
+ log.debug("JBoss Cache is already started with a transaction manager ("
+ + cacheTm + ") that is not equal to our own (" + tm + ")");
+ }
} else {
// Configure the cache to use our TM
cacheConfig.getRuntimeConfig().setTransactionManager(tm);
16 years, 6 months
Hibernate SVN: r14755 - in search/trunk/src: java/org/hibernate/search/backend/configuration and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2008-06-09 12:58:31 -0400 (Mon, 09 Jun 2008)
New Revision: 14755
Added:
search/trunk/src/test/org/hibernate/search/test/SerializationTestHelper.java
Modified:
search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java
search/trunk/src/java/org/hibernate/search/backend/configuration/MaskedProperty.java
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java
search/trunk/src/test/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java
search/trunk/src/test/org/hibernate/search/test/configuration/MaskedPropertiesTest.java
Log:
fix Serialization for LuceneIndexingParameters and MaskedProperty; added serializability test helper.
Modified: search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2008-06-09 15:57:07 UTC (rev 14754)
+++ search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2008-06-09 16:58:31 UTC (rev 14755)
@@ -28,8 +28,6 @@
private static final long serialVersionUID = 5424606407623591663L;
- private final Logger log = LoggerFactory.getLogger( LuceneIndexingParameters.class );
-
// value keyword
public static final String EXPLICIT_DEFAULT_VALUE = "default";
// property path keywords
@@ -47,12 +45,14 @@
Properties transactionProps = new MaskedProperty( indexingParameters, TRANSACTION );
//get keys for "batch" (defaulting to transaction)
Properties batchProps = new MaskedProperty( indexingParameters, BATCH, transactionProps ); //TODO to close HSEARCH-201 just remove 3° parameter
- transactionIndexParameters = new ParameterSet( transactionProps, TRANSACTION );
- batchIndexParameters = new ParameterSet( batchProps, BATCH );
- doSanityChecks( transactionIndexParameters, batchIndexParameters );
+ //logger only used during object construction: (logger not serializable).
+ Logger log = LoggerFactory.getLogger( LuceneIndexingParameters.class );
+ transactionIndexParameters = new ParameterSet( transactionProps, TRANSACTION, log );
+ batchIndexParameters = new ParameterSet( batchProps, BATCH, log );
+ doSanityChecks( transactionIndexParameters, batchIndexParameters, log );
}
- private void doSanityChecks(ParameterSet transParams, ParameterSet batchParams) {
+ private void doSanityChecks(ParameterSet transParams, ParameterSet batchParams, Logger log) {
if ( log.isWarnEnabled() ) {
Integer maxFieldLengthTransaction = transParams.parameters.get( MAX_FIELD_LENGTH );
Integer maxFieldLengthBatch = transParams.parameters.get( MAX_FIELD_LENGTH );
@@ -77,13 +77,13 @@
return batchIndexParameters;
}
- public class ParameterSet implements Serializable {
+ public static class ParameterSet implements Serializable {
private static final long serialVersionUID = -6121723702279869524L;
final Map<IndexWriterSetting, Integer> parameters = new EnumMap<IndexWriterSetting, Integer>(IndexWriterSetting.class);
- public ParameterSet(Properties prop, String paramName) {
+ public ParameterSet(Properties prop, String paramName, Logger log) {
//don't iterate on property entries as we know all the keys:
for ( IndexWriterSetting t : IndexWriterSetting.values() ) {
String key = t.getKey();
@@ -127,6 +127,32 @@
}
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((parameters == null) ? 0 : parameters.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ParameterSet other = (ParameterSet) obj;
+ if (parameters == null) {
+ if (other.parameters != null)
+ return false;
+ } else if (!parameters.equals(other.parameters))
+ return false;
+ return true;
+ }
+
}
public void applyToWriter(IndexWriter writer, boolean batch) {
Modified: search/trunk/src/java/org/hibernate/search/backend/configuration/MaskedProperty.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/configuration/MaskedProperty.java 2008-06-09 15:57:07 UTC (rev 14754)
+++ search/trunk/src/java/org/hibernate/search/backend/configuration/MaskedProperty.java 2008-06-09 16:58:31 UTC (rev 14755)
@@ -2,6 +2,8 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -29,7 +31,7 @@
private static final long serialVersionUID = -593307257383085113L;
- private final Logger log = LoggerFactory.getLogger( MaskedProperty.class );
+ private transient Logger log = LoggerFactory.getLogger( MaskedProperty.class );
private final Properties masked;
private final Properties fallBack;
private final String radix;
@@ -344,4 +346,14 @@
return true;
}
+ private void readObject(ObjectInputStream aInputStream) throws ClassNotFoundException, IOException {
+ //always perform the default de-serialization first
+ aInputStream.defaultReadObject();
+ log = LoggerFactory.getLogger( MaskedProperty.class );
+ }
+
+ private void writeObject(ObjectOutputStream aOutputStream) throws IOException {
+ aOutputStream.defaultWriteObject();
+ }
+
}
Modified: search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java 2008-06-09 15:57:07 UTC (rev 14754)
+++ search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java 2008-06-09 16:58:31 UTC (rev 14755)
@@ -146,7 +146,7 @@
}
/**
- * Users may configure the number of KB to use as
+ * Users may configure the number of MB to use as
* "chunk size" for large file copy operations performed
* by DirectoryProviders.
* @param directoryProviderName
Added: search/trunk/src/test/org/hibernate/search/test/SerializationTestHelper.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/SerializationTestHelper.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/SerializationTestHelper.java 2008-06-09 16:58:31 UTC (rev 14755)
@@ -0,0 +1,107 @@
+package org.hibernate.search.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.search.test.SerializationTestHelper.Foo.TestInnerClass;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Sanne Grinovero
+ */
+public class SerializationTestHelper extends TestCase {
+
+ /**
+ * Duplicates an object using Serialization, it moves
+ * state to and from a buffer. Should be used to test
+ * correct serializability.
+ * @param o The object to "clone"
+ * @return the clone.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ public static Object duplicateBySerialization(Object o) throws IOException, ClassNotFoundException {
+ //Serialize to buffer:
+ java.io.ByteArrayOutputStream outStream = new java.io.ByteArrayOutputStream();
+ ObjectOutputStream objectOutStream = new ObjectOutputStream( outStream );
+ objectOutStream.writeObject( o );
+ objectOutStream.flush();
+ objectOutStream.close();
+ //buffer version of Object:
+ byte[] objectBuffer = outStream.toByteArray();
+ //deserialize to new instance:
+ java.io.ByteArrayInputStream inStream = new ByteArrayInputStream( objectBuffer );
+ ObjectInputStream objectInStream = new ObjectInputStream( inStream );
+ Object copy = objectInStream.readObject();
+ return copy;
+ }
+
+ public void testSelf() throws IOException, ClassNotFoundException {
+ Foo a = new Foo();
+ a.list.add( new TestInnerClass(30) );
+ Foo b = (Foo) duplicateBySerialization( a );
+ assertEquals( Integer.valueOf(6), a.integer);
+ assertEquals( Integer.valueOf(7), b.integer);
+ assertEquals( a.list, b.list );
+ }
+
+ static class Foo implements Serializable {
+
+ List<TestInnerClass> list = new ArrayList<TestInnerClass>();
+ transient Integer integer = Integer.valueOf( 6 );
+
+ static class TestInnerClass implements Serializable {
+ private final int v;
+
+ public TestInnerClass(int i) {
+ v = i;
+ }
+
+ public void print() {
+ System.out.println(v);
+ }
+
+ public String toString(){
+ return ""+v;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + v;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final TestInnerClass other = (TestInnerClass) obj;
+ if (v != other.v)
+ return false;
+ return true;
+ }
+ }
+
+ private void readObject(ObjectInputStream aInputStream) throws ClassNotFoundException, IOException {
+ aInputStream.defaultReadObject();
+ integer = Integer.valueOf( 7 );
+ }
+
+ private void writeObject(ObjectOutputStream aOutputStream) throws IOException {
+ aOutputStream.defaultWriteObject();
+ }
+ }
+
+}
Modified: search/trunk/src/test/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java 2008-06-09 15:57:07 UTC (rev 14754)
+++ search/trunk/src/test/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java 2008-06-09 16:58:31 UTC (rev 14755)
@@ -1,6 +1,11 @@
package org.hibernate.search.test.configuration;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.hibernate.search.backend.LuceneIndexingParameters;
import org.hibernate.search.test.Document;
+import org.hibernate.search.test.SerializationTestHelper;
import org.hibernate.search.test.query.Author;
import org.hibernate.search.test.query.Book;
import static org.hibernate.search.backend.configuration.IndexWriterSetting.MAX_BUFFERED_DOCS;
@@ -85,6 +90,14 @@
assertValueIsDefault( Document.class, TRANSACTION, RAM_BUFFER_SIZE );
}
+ public void testSerializability() throws IOException, ClassNotFoundException {
+ LuceneIndexingParameters param = new LuceneIndexingParameters( new Properties() );
+ LuceneIndexingParameters paramCopy = (LuceneIndexingParameters)
+ SerializationTestHelper.duplicateBySerialization( param );
+ assertEquals(param.getBatchIndexParameters(), paramCopy.getBatchIndexParameters());
+ assertEquals(param.getTransactionIndexParameters(), paramCopy.getTransactionIndexParameters());
+ }
+
protected Class[] getMappings() {
return new Class[] {
Book.class,
Modified: search/trunk/src/test/org/hibernate/search/test/configuration/MaskedPropertiesTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/configuration/MaskedPropertiesTest.java 2008-06-09 15:57:07 UTC (rev 14754)
+++ search/trunk/src/test/org/hibernate/search/test/configuration/MaskedPropertiesTest.java 2008-06-09 16:58:31 UTC (rev 14755)
@@ -1,8 +1,10 @@
package org.hibernate.search.test.configuration;
+import java.io.IOException;
import java.util.Properties;
import org.hibernate.search.backend.configuration.MaskedProperty;
+import org.hibernate.search.test.SerializationTestHelper;
/**
* @author Sanne Grinovero
@@ -37,4 +39,14 @@
assertEquals( "5" , transaction.getProperty( "max_merge_docs" ) );
}
+ public void testSerializability() throws IOException, ClassNotFoundException {
+ Properties cfg = new Properties();
+ cfg.setProperty( "base.key", "value" );
+ MaskedProperty originalProps = new MaskedProperty( cfg, "base" );
+ MaskedProperty theCopy = (MaskedProperty)
+ SerializationTestHelper.duplicateBySerialization( originalProps );
+ //this is also testing the logger (transient) has been restored:
+ assertEquals( "value", theCopy.getProperty( "key" ) );
+ }
+
}
16 years, 6 months
Hibernate SVN: r14754 - annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-09 11:57:07 -0400 (Mon, 09 Jun 2008)
New Revision: 14754
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CountryAttitude.java
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/Matrix.java
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/TestCourse.java
Log:
ANN-723
- Modified the Matrix class to use a SortedMap in order to test the issue (actual fix in commons-annotations)
- Minor code clean ups
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java 2008-06-09 15:50:47 UTC (rev 14753)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java 2008-06-09 15:57:07 UTC (rev 14754)
@@ -1,7 +1,6 @@
//$Id$
package org.hibernate.test.annotations.collectionelement;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -14,9 +13,11 @@
/**
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
+@SuppressWarnings("unchecked")
public class CollectionElementTest extends TestCase {
-
+
public void testSimpleElement() throws Exception {
assertEquals(
"BoyFavoriteNumbers",
@@ -180,7 +181,6 @@
assertEquals( 1, l.size() );
TestCourse t = (TestCourse) s.get( TestCourse.class, test.getTestCourseId() );
- Iterator it = t.getTitle().getVariations().values().iterator();
assertEquals( 1, t.getTitle().getVariations().size() );
tx.rollback();
@@ -202,7 +202,6 @@
s.close();
}
-
protected Class[] getMappings() {
return new Class[] {
Boy.class,
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CountryAttitude.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CountryAttitude.java 2008-06-09 15:50:47 UTC (rev 14753)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CountryAttitude.java 2008-06-09 15:57:07 UTC (rev 14754)
@@ -17,7 +17,7 @@
private boolean likes;
// TODO: This currently does not work
- //@ManyToOne(optional = false)
+// @ManyToOne(optional = false)
// public Boy getBoy() {
// return boy;
// }
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/Matrix.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/Matrix.java 2008-06-09 15:50:47 UTC (rev 14753)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/Matrix.java 2008-06-09 15:57:07 UTC (rev 14754)
@@ -2,13 +2,17 @@
package org.hibernate.test.annotations.collectionelement;
import java.util.Map;
-import java.util.HashMap;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
+import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.MapKey;
-import org.hibernate.annotations.CollectionOfElements;
+import org.hibernate.annotations.Sort;
+import org.hibernate.annotations.SortType;
import org.hibernate.annotations.Type;
/**
@@ -19,10 +23,12 @@
@Id
@GeneratedValue
private Integer id;
+
@MapKey(type = @Type(type="integer") )
@CollectionOfElements
+ @Sort(type = SortType.NATURAL)
@Type(type = "float")
- private Map<Integer, Float> values = new HashMap<Integer, Float>();
+ private SortedMap<Integer, Float> values = new TreeMap<Integer, Float>();
public Integer getId() {
return id;
@@ -36,7 +42,7 @@
return values;
}
- public void setValues(Map<Integer, Float> values) {
+ public void setValues(SortedMap<Integer, Float> values) {
this.values = values;
}
}
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/TestCourse.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/TestCourse.java 2008-06-09 15:50:47 UTC (rev 14753)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/TestCourse.java 2008-06-09 15:57:07 UTC (rev 14754)
@@ -1,15 +1,14 @@
//$Id$
package org.hibernate.test.annotations.collectionelement;
-import javax.persistence.Id;
-import javax.persistence.Table;
import javax.persistence.Embedded;
-import javax.persistence.GenerationType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
-import org.hibernate.annotations.ParamDef;
import org.hibernate.annotations.FilterDef;
+import org.hibernate.annotations.ParamDef;
/**
* @author Emmanuel Bernard
16 years, 6 months
Hibernate SVN: r14753 - in commons-annotations/trunk: src/java/org/hibernate/annotations/common/reflection/java and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-09 11:50:47 -0400 (Mon, 09 Jun 2008)
New Revision: 14753
Modified:
commons-annotations/trunk/
commons-annotations/trunk/src/java/org/hibernate/annotations/common/reflection/java/JavaXCollectionType.java
Log:
ANN-723
- Fixed wrong usage Class.isAssignableFrom(). Caller and callee had to be switched
- Modified svn ignore pattern
Property changes on: commons-annotations/trunk
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
+ .*
build
test_output
target
Modified: commons-annotations/trunk/src/java/org/hibernate/annotations/common/reflection/java/JavaXCollectionType.java
===================================================================
--- commons-annotations/trunk/src/java/org/hibernate/annotations/common/reflection/java/JavaXCollectionType.java 2008-06-09 12:42:12 UTC (rev 14752)
+++ commons-annotations/trunk/src/java/org/hibernate/annotations/common/reflection/java/JavaXCollectionType.java 2008-06-09 15:50:47 UTC (rev 14753)
@@ -1,3 +1,4 @@
+// $Id:$
package org.hibernate.annotations.common.reflection.java;
import java.lang.reflect.ParameterizedType;
@@ -15,6 +16,7 @@
* @author Emmanuel Bernard
* @author Paolo Perrotta
*/
+@SuppressWarnings("unchecked")
class JavaXCollectionType extends JavaXType {
public JavaXCollectionType(Type type, TypeEnvironment context, JavaReflectionManager factory) {
@@ -36,8 +38,8 @@
Type[] args = parameterizedType.getActualTypeArguments();
Type componentType;
Class<? extends Collection> collectionClass = getCollectionClass();
- if ( collectionClass.isAssignableFrom( Map.class )
- || collectionClass.isAssignableFrom( SortedMap.class ) ) {
+ if ( Map.class.isAssignableFrom( collectionClass )
+ || SortedMap.class.isAssignableFrom( collectionClass ) ) {
componentType = args[1];
}
else {
@@ -52,7 +54,7 @@
return new TypeSwitch<XClass>() {
@Override
public XClass caseParameterizedType(ParameterizedType parameterizedType) {
- if ( getCollectionClass().isAssignableFrom( Map.class ) ) {
+ if ( Map.class.isAssignableFrom( getCollectionClass() ) ) {
return toXClass( parameterizedType.getActualTypeArguments()[0] );
}
return null;
Property changes on: commons-annotations/trunk/src/java/org/hibernate/annotations/common/reflection/java/JavaXCollectionType.java
___________________________________________________________________
Name: svn:keywords
+ Id
16 years, 6 months
Hibernate SVN: r14752 - annotations/trunk/src/test/org/hibernate/test/annotations/naturalid.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-09 08:42:12 -0400 (Mon, 09 Jun 2008)
New Revision: 14752
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnManyToOne.java
annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java
Log:
Added keyword substitution
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnManyToOne.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java 2008-06-09 12:40:46 UTC (rev 14751)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java 2008-06-09 12:42:12 UTC (rev 14752)
@@ -1,4 +1,4 @@
-//$Id: NaturalIdTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
+//$Id$
package org.hibernate.test.annotations.naturalid;
import java.util.List;
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
16 years, 6 months
Hibernate SVN: r14751 - in annotations/trunk/src/test: org/hibernate/test/annotations/naturalid and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-09 08:40:46 -0400 (Mon, 09 Jun 2008)
New Revision: 14751
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnManyToOne.java
annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java
Modified:
annotations/trunk/src/test/log4j.properties
annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java
Log:
* Added test case for ANN-750
* Improved the tests for NaturalId
* Added chainsaw logger to log4j for test configuration
Modified: annotations/trunk/src/test/log4j.properties
===================================================================
--- annotations/trunk/src/test/log4j.properties 2008-06-06 15:51:05 UTC (rev 14750)
+++ annotations/trunk/src/test/log4j.properties 2008-06-09 12:40:46 UTC (rev 14751)
@@ -5,11 +5,18 @@
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
-#log4j.appender.file=org.apache.log4j.FileAppender
-#log4j.appender.file.File=hibernate.log
-#log4j.appender.file.layout=org.apache.log4j.PatternLayout
-#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.File=hibernate.log
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+### direct messages to socket - chainsaw ###
+log4j.appender.socket=org.apache.log4j.net.SocketAppender
+log4j.appender.socket.remoteHost=localhost
+log4j.appender.socket.port=4560
+log4j.appender.socket.locationInfo=true
+
+
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
Added: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnManyToOne.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnManyToOne.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnManyToOne.java 2008-06-09 12:40:46 UTC (rev 14751)
@@ -0,0 +1,42 @@
+package org.hibernate.test.annotations.naturalid;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.annotations.NaturalId;
+
+@Entity
+/**
+ * Test case for NaturalId annotation - ANN-750
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+class NaturalIdOnManyToOne {
+
+ @Id
+ @GeneratedValue
+ int id;
+
+ @NaturalId
+ @ManyToOne
+ Citizen citizen;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Citizen getCitizen() {
+ return citizen;
+ }
+
+ public void setCitizen(Citizen citizen) {
+ this.citizen = citizen;
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnManyToOne.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java 2008-06-09 12:40:46 UTC (rev 14751)
@@ -0,0 +1,95 @@
+//$Id: NaturalIdTest.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
+package org.hibernate.test.annotations.naturalid;
+
+import java.util.List;
+
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.stat.Statistics;
+import org.hibernate.test.annotations.TestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test case for NaturalId annotation. See ANN-750.
+ *
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+@SuppressWarnings("unchecked")
+public class NaturalIdOnSingleManyToOneTest extends TestCase {
+
+ private Logger log = LoggerFactory.getLogger(NaturalIdOnManyToOne.class);
+
+ public void testMappingProperties() {
+ log.warn("Commented out test");
+//TODO Fix test
+// ClassMetadata metaData = getSessions().getClassMetadata(
+// NaturalIdOnManyToOne.class);
+// assertTrue("Class should have a natural key", metaData
+// .hasNaturalIdentifier());
+// int[] propertiesIndex = metaData.getNaturalIdentifierProperties();
+// assertTrue("Wrong number of elements", propertiesIndex.length == 1);
+ }
+
+ public void testManyToOneNaturalIdCached() {
+ NaturalIdOnManyToOne singleManyToOne = new NaturalIdOnManyToOne();
+ Citizen c1 = new Citizen();
+ c1.setFirstname("Emmanuel");
+ c1.setLastname("Bernard");
+ c1.setSsn("1234");
+
+ State france = new State();
+ france.setName("Ile de France");
+ c1.setState(france);
+
+ singleManyToOne.setCitizen(c1);
+
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist(france);
+ s.persist(c1);
+ s.persist(singleManyToOne);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ Criteria criteria = s.createCriteria(NaturalIdOnManyToOne.class);
+ criteria.add(Restrictions.naturalId().set("citizen", c1));
+ criteria.setCacheable(true);
+
+ Statistics stats = getSessions().getStatistics();
+ stats.setStatisticsEnabled(true);
+ stats.clear();
+ assertEquals("Cache hits should be empty", 0, stats
+ .getQueryCacheHitCount());
+
+ // first query
+ List results = criteria.list();
+ assertEquals(1, results.size());
+ assertEquals("Cache hits should be empty", 0, stats
+ .getQueryCacheHitCount());
+ assertEquals("First query should be a miss", 1, stats
+ .getQueryCacheMissCount());
+ assertEquals("Query result should be added to cache", 1, stats
+ .getQueryCachePutCount());
+
+ // query a second time - result should be cached
+ results = criteria.list();
+ assertEquals("Cache hits should be empty", 1, stats
+ .getQueryCacheHitCount());
+
+ // cleanup
+ tx.rollback();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] { Citizen.class, State.class,
+ NaturalIdOnManyToOne.class };
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java 2008-06-06 15:51:05 UTC (rev 14750)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java 2008-06-09 12:40:46 UTC (rev 14751)
@@ -3,43 +3,135 @@
import java.util.List;
+import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.stat.Statistics;
import org.hibernate.test.annotations.TestCase;
/**
+ * Test case for NaturalId annotation
+ *
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
+@SuppressWarnings("unchecked")
public class NaturalIdTest extends TestCase {
- public void testNaturalId() {
- Citizen c = new Citizen();
- c.setFirstname( "Emmanuel" );
- c.setLastname( "Bernard" );
- c.setSsn( "1234" );
- State ste = new State();
- ste.setName( "Ile de France");
- c.setState( ste);
+ public void testMappingProperties() {
+ ClassMetadata metaData = getSessions().getClassMetadata(
+ Citizen.class);
+ assertTrue("Class should have a natural key", metaData
+ .hasNaturalIdentifier());
+ int[] propertiesIndex = metaData.getNaturalIdentifierProperties();
+ assertTrue("Wrong number of elements", propertiesIndex.length == 1);
+ }
+
+ public void testNaturalIdCached() {
+ saveSomeCitizens();
+
Session s = openSession();
Transaction tx = s.beginTransaction();
- s.persist( ste );
- s.persist( c );
- s.flush();
- s.clear();
- List results = s.createCriteria( Citizen.class )
- .add( Restrictions.naturalId().set( "ssn", "1234" ).set( "state", ste ) )
- .list();
- assertEquals( 1, results.size() );
+ State france = (State) s.load(State.class, new Integer(2));
+ Criteria criteria = s.createCriteria(Citizen.class);
+ criteria.add(Restrictions.naturalId().set("ssn", "1234").set("state",
+ france));
+ criteria.setCacheable(true);
+ Statistics stats = getSessions().getStatistics();
+ stats.setStatisticsEnabled(true);
+ stats.clear();
+ assertEquals("Cache hits should be empty", 0, stats
+ .getQueryCacheHitCount());
+
+ // first query
+ List results = criteria.list();
+ assertEquals(1, results.size());
+ assertEquals("Cache hits should be empty", 0, stats
+ .getQueryCacheHitCount());
+ assertEquals("First query should be a miss", 1, stats
+ .getQueryCacheMissCount());
+ assertEquals("Query result should be added to cache", 1, stats
+ .getQueryCachePutCount());
+
+ // query a second time - result should be cached
+ results = criteria.list();
+ assertEquals("Cache hits should be empty", 1, stats
+ .getQueryCacheHitCount());
+
+ // cleanup
tx.rollback();
s.close();
}
+ public void testNaturalIdUncached() {
+
+ saveSomeCitizens();
+
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ State france = (State) s.load(State.class, new Integer(2));
+ Criteria criteria = s.createCriteria(Citizen.class);
+ criteria.add(Restrictions.naturalId().set("ssn", "1234").set("state",
+ france));
+ criteria.setCacheable(false);
+
+ Statistics stats = getSessions().getStatistics();
+ stats.setStatisticsEnabled(true);
+ stats.clear();
+ assertEquals("Cache hits should be empty", 0, stats
+ .getQueryCacheHitCount());
+
+ // first query
+ List results = criteria.list();
+ assertEquals(1, results.size());
+ assertEquals("Cache hits should be empty", 0, stats
+ .getQueryCacheHitCount());
+ assertEquals("Query result should be added to cache", 0, stats
+ .getQueryCachePutCount());
+
+ // query a second time
+ results = criteria.list();
+ assertEquals("Cache hits should be empty", 0, stats
+ .getQueryCacheHitCount());
+
+ // cleanup
+ tx.rollback();
+ s.close();
+ }
+
protected Class[] getMappings() {
- return new Class[] {
- Citizen.class,
- State.class
- };
+ return new Class[] { Citizen.class, State.class,
+ NaturalIdOnManyToOne.class };
}
+
+ private void saveSomeCitizens() {
+ Citizen c1 = new Citizen();
+ c1.setFirstname("Emmanuel");
+ c1.setLastname("Bernard");
+ c1.setSsn("1234");
+
+ State france = new State();
+ france.setName("Ile de France");
+ c1.setState(france);
+
+ Citizen c2 = new Citizen();
+ c2.setFirstname("Gavin");
+ c2.setLastname("King");
+ c2.setSsn("000");
+ State australia = new State();
+ australia.setName("Australia");
+ c2.setState(australia);
+
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist(australia);
+ s.persist(france);
+ s.persist(c1);
+ s.persist(c2);
+ tx.commit();
+ s.close();
+ }
}
16 years, 6 months