Author: jcosta(a)redhat.com
Date: 2009-04-21 10:01:06 -0400 (Tue, 21 Apr 2009)
New Revision: 16382
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Address.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Article.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Employee.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Light.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Lighter.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/XmlAttributeOverrideTest.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/XmlTest.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm.xml
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm2.xml
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm3.xml
Modified:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/cascade/Author.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/cascade/Song.java
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/orm.xml
Log:
JBPAPP-1078 EJB-413 - Removed a dependency on sequences for XMLTests and added a specific
package with sequences, to be used only on databases which supports it. For branch
v3_4_0_GA_CP
Modified:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/cascade/Author.java
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/cascade/Author.java 2009-04-21
13:45:48 UTC (rev 16381)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/cascade/Author.java 2009-04-21
14:01:06 UTC (rev 16382)
@@ -2,18 +2,15 @@
package org.hibernate.ejb.test.cascade;
import javax.persistence.Entity;
-import javax.persistence.Id;
import javax.persistence.GeneratedValue;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.GenerationType;
+import javax.persistence.Id;
/**
* @author Emmanuel Bernard
*/
@Entity
public class Author {
- @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"ENTITY2_SEQ")
- @SequenceGenerator(name = "ENTITY2_SEQ")
+ @Id @GeneratedValue
private Long id;
}
Modified:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/cascade/Song.java
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/cascade/Song.java 2009-04-21
13:45:48 UTC (rev 16381)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/cascade/Song.java 2009-04-21
14:01:06 UTC (rev 16382)
@@ -2,20 +2,18 @@
package org.hibernate.ejb.test.cascade;
import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
import javax.persistence.ManyToOne;
-import javax.persistence.GenerationType;
-import javax.persistence.SequenceGenerator;
/**
* @author Emmanuel Bernard
*/
@Entity
public class Song {
- @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"ENTITY1_SEQ")
- @SequenceGenerator(name = "ENTITY1_SEQ") private Long id;
+ @Id @GeneratedValue
+ private Long id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
private Author author;
Modified: entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/orm.xml
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/orm.xml 2009-04-21
13:45:48 UTC (rev 16381)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/orm.xml 2009-04-21
14:01:06 UTC (rev 16382)
@@ -26,7 +26,7 @@
metadata-complete="false">
<attributes>
<id name="id">
- <generated-value strategy="SEQUENCE"/>
+ <generated-value strategy="AUTO"/>
</id>
</attributes>
</entity>
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Address.java
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Address.java
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Address.java 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,54 @@
+//$Id: $
+package org.hibernate.ejb.test.xml.sequences;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Address {
+ private String street;
+ private String city;
+ private String state;
+ private String zip;
+
+ public Address() {
+ }
+
+ public Address(String street, String city, String state, String zip) {
+ this.street = street;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getZip() {
+ return zip;
+ }
+
+ public void setZip(String zip) {
+ this.zip = zip;
+ }
+}
\ No newline at end of file
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Article.java
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Article.java
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Article.java 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,49 @@
+//$Id: $
+package org.hibernate.ejb.test.xml.sequences;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.GeneratedValue;
+import javax.persistence.CascadeType;
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinColumn;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name = "ITEM")
+(a)org.hibernate.annotations.BatchSize(size = 10)
+public class Article {
+ private Integer id;
+ private String name;
+
+ private Article nextArticle;
+
+ @Id @GeneratedValue public Integer getId() {
+ return id;
+ }
+ public void setId(Integer id) {
+ this.id = id;
+ }
+ @Column(name="poopoo")
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ @ManyToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "NEXT_MESSAGE_ID")
+ public Article getNextArticle() {
+ return nextArticle;
+ }
+
+ public void setNextArticle(Article nextArticle) {
+ this.nextArticle = nextArticle;
+ }
+}
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Employee.java
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Employee.java
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Employee.java 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,66 @@
+//$Id: $
+package org.hibernate.ejb.test.xml.sequences;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Employee {
+ @Id
+ Long id;
+ String name;
+/*
+ @Embedded
+ @AttributeOverrides({
+ @AttributeOverride(name = "street", column = @Column(name =
"HA_street")),
+ @AttributeOverride(name = "city", column = @Column(name =
"HA_city")),
+ @AttributeOverride(name = "state", column = @Column(name =
"HA_state")),
+ @AttributeOverride(name = "zip", column = @Column(name =
"HA_zip")) })
+*/
+ Address homeAddress;
+
+/*
+ @Embedded
+ @AttributeOverrides({
+ @AttributeOverride(name = "street", column = @Column(name =
"MA_street")),
+ @AttributeOverride(name = "city", column = @Column(name =
"MA_city")),
+ @AttributeOverride(name = "state", column = @Column(name =
"MA_state")),
+ @AttributeOverride(name = "zip", column = @Column(name =
"MA_zip")) })
+*/
+ Address mailAddress;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Address getHomeAddress() {
+ return homeAddress;
+ }
+
+ public void setHomeAddress(Address homeAddress) {
+ this.homeAddress = homeAddress;
+ }
+
+ public Address getMailAddress() {
+ return mailAddress;
+ }
+
+ public void setMailAddress(Address mailAddress) {
+ this.mailAddress = mailAddress;
+ }
+}
\ No newline at end of file
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Light.java
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Light.java
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Light.java 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,10 @@
+//$Id: $
+package org.hibernate.ejb.test.xml.sequences;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Light {
+ public String name;
+ public String power;
+}
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Lighter.java
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Lighter.java
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/Lighter.java 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,10 @@
+//$Id: $
+package org.hibernate.ejb.test.xml.sequences;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Lighter {
+ public String name;
+ public String power;
+}
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/XmlAttributeOverrideTest.java
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/XmlAttributeOverrideTest.java
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/XmlAttributeOverrideTest.java 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,41 @@
+//$Id: $
+package org.hibernate.ejb.test.xml.sequences;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.ejb.test.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class XmlAttributeOverrideTest extends TestCase {
+
+ public void testAttributeOverriding() throws Exception {
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+
+ Employee e = new Employee();
+ e.setId(Long.valueOf(100));
+ e.setName("Bubba");
+ e.setHomeAddress(new Address("123 Main St", "New York",
"NY", "11111"));
+ e.setMailAddress(new Address("P.O. Box 123", "New York",
"NY", "11111"));
+
+ em.persist(e);
+
+ em.flush();
+
+ em.getTransaction().rollback();
+ em.close();
+ }
+
+ public Class[] getAnnotatedClasses() {
+ return new Class[0];
+ }
+
+ @Override
+ public String[] getEjb3DD() {
+ return new String[] {
+ "org/hibernate/ejb/test/xml/sequences/orm3.xml"
+ };
+ }
+}
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/XmlTest.java
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/XmlTest.java
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/XmlTest.java 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,34 @@
+//$Id: $
+package org.hibernate.ejb.test.xml.sequences;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.dialect.Dialect;
+import org.hibernate.ejb.test.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class XmlTest extends TestCase {
+ public void testXmlMappingCorrectness() throws Exception {
+ EntityManager em = getOrCreateEntityManager();
+ em.close();
+ }
+
+ public Class[] getAnnotatedClasses() {
+ return new Class[0];
+ }
+
+ @Override
+ public boolean appliesTo(Dialect dialect) {
+ return dialect.supportsSequences();
+ }
+
+ @Override
+ public String[] getEjb3DD() {
+ return new String[] {
+ "org/hibernate/ejb/test/xml/sequences/orm.xml",
+ "org/hibernate/ejb/test/xml/sequences/orm2.xml",
+ };
+ }
+}
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm.xml
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm.xml
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm.xml 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
orm_1_0.xsd"
+ version="1.0"
+ >
+ <persistence-unit-metadata>
+ <persistence-unit-defaults>
+ <schema>MY_SCHEMA</schema>
+ <catalog>MY_CATALOG</catalog>
+ <access>PROPERTY</access>
+ <cascade-persist/>
+ </persistence-unit-defaults>
+ </persistence-unit-metadata>
+ <package>org.hibernate.ejb.test.xml.sequences</package>
+ <entity class="Light" metadata-complete="true"
access="FIELD">
+ <attributes>
+ <id name="name">
+ <column name="fld_id"/>
+ </id>
+ <basic name="power"></basic>
+ </attributes>
+ </entity>
+ <entity class="Article"
+ metadata-complete="false">
+ <attributes>
+ <id name="id">
+ <generated-value strategy="SEQUENCE"/>
+ </id>
+ </attributes>
+ </entity>
+</entity-mappings>
\ No newline at end of file
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm2.xml
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm2.xml
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm2.xml 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
orm_1_0.xsd"
+ version="1.0"
+ >
+ <entity class="org.hibernate.ejb.test.xml.sequences.Lighter"
name="ALighter" access="FIELD" metadata-complete="true">
+ <attributes>
+ <id name="name">
+ <column name="fld_id"/>
+ </id>
+ <basic name="power"></basic>
+ </attributes>
+ </entity>
+ <!-- entity class="NoPackageEntity" name="ALighter"
access="FIELD" metadata-complete="true">
+ <attributes>
+ <id name="id"/>
+ <basic name="name"/>
+ </attributes>
+ </entity -->
+ <embeddable class="NoPackageEntity" access="FIELD">
+ <attributes>
+ <basic name="name"/>
+ </attributes>
+ </embeddable>
+</entity-mappings>
\ No newline at end of file
Added:
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm3.xml
===================================================================
---
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm3.xml
(rev 0)
+++
entitymanager/branches/v3_4_0_GA_CP/src/test/org/hibernate/ejb/test/xml/sequences/orm3.xml 2009-04-21
14:01:06 UTC (rev 16382)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
+ version="1.0">
+
+ <entity class="org.hibernate.ejb.test.xml.sequences.Employee"
metadata-complete="false" access="FIELD">
+ <attributes>
+ <id name="id"/>
+ <basic name="name"/>
+
+ <embedded name="homeAddress">
+ <attribute-override name="street">
+ <column name="home_street"/>
+ </attribute-override>
+ <attribute-override name="city">
+ <column name="home_city"/>
+ </attribute-override>
+ <attribute-override name="state">
+ <column name="home_state"/>
+ </attribute-override>
+ <attribute-override name="zip">
+ <column name="home_zip"/>
+ </attribute-override>
+ </embedded>
+
+ <embedded name="mailAddress">
+ <attribute-override name="street">
+ <column name="mail_street"/>
+ </attribute-override>
+ <attribute-override name="city">
+ <column name="mail_city"/>
+ </attribute-override>
+ <attribute-override name="state">
+ <column name="mail_state"/>
+ </attribute-override>
+ <attribute-override name="zip">
+ <column name="mail_zip"/>
+ </attribute-override>
+ </embedded>
+
+ </attributes>
+ </entity>
+
+ <embeddable class="org.hibernate.ejb.test.xml.sequences.Address">
+ <attributes>
+ <basic name="street"/>
+ <basic name="city"/>
+ <basic name="state"/>
+ <basic name="zip"/>
+ </attributes>
+ </embeddable>
+
+</entity-mappings>
\ No newline at end of file