Author: steve.ebersole(a)jboss.com
Date: 2009-12-16 17:12:45 -0500 (Wed, 16 Dec 2009)
New Revision: 18250
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/EmbeddedTypeTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Product.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/ShelfLife.java
Log:
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/EmbeddedTypeTest.java
===================================================================
---
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/EmbeddedTypeTest.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/EmbeddedTypeTest.java 2009-12-16
22:12:45 UTC (rev 18250)
@@ -0,0 +1,58 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.ejb.metamodel;
+
+import javax.persistence.EntityManager;
+import javax.persistence.metamodel.SingularAttribute;
+
+import org.hibernate.ejb.test.TestCase;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class EmbeddedTypeTest extends TestCase {
+ @Override
+ public Class[] getAnnotatedClasses() {
+ return new Class[] {
+ Product.class, ShelfLife.class
+ };
+ }
+
+ public void testSingularAttributeAccessByNameFailureExpected() {
+ // HHH-4702
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+
+ SingularAttribute soldDate_ = em.getMetamodel().embeddable( ShelfLife.class )
+ .getSingularAttribute( "soldDate" );
+ assertEquals( java.sql.Date.class, soldDate_.getBindableJavaType());
+ assertEquals( java.sql.Date.class, soldDate_.getType().getJavaType() );
+ assertEquals( java.sql.Date.class, soldDate_.getJavaType() );
+
+ em.getTransaction().commit();
+ em.close();
+ }
+}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Product.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Product.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Product.java 2009-12-16
22:12:45 UTC (rev 18250)
@@ -0,0 +1,141 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.ejb.metamodel;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorType;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.SecondaryTable;
+import javax.persistence.Table;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+@Entity
+@Table(name = "PRODUCT_TABLE")
+@SecondaryTable(name = "PRODUCT_DETAILS", pkJoinColumns =
@PrimaryKeyJoinColumn(name = "ID"))
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+@DiscriminatorColumn(name = "PRODUCT_TYPE", discriminatorType =
DiscriminatorType.STRING)
+@DiscriminatorValue("Product")
+public class Product implements java.io.Serializable {
+ private String id;
+ private String name;
+ private double price;
+ private int quantity;
+ private long partNumber;
+ private String wareHouse;
+ private ShelfLife shelfLife;
+
+ public Product() {
+ }
+
+ public Product(String id, String name, double price, int quantity, long partNumber) {
+ this.id = id;
+ this.name = name;
+ this.price = price;
+ this.quantity = quantity;
+ this.partNumber = partNumber;
+ }
+
+ @Id
+ @Column(name = "ID")
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Column(name = "NAME")
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Column(name = "PRICE")
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+
+ @Column(name = "QUANTITY")
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int v) {
+ this.quantity = v;
+ }
+
+ @Column(name = "PNUM")
+ public long getPartNumber() {
+ return partNumber;
+ }
+
+ public void setPartNumber(long v) {
+ this.partNumber = v;
+ }
+
+ @Column(name = "WHOUSE", nullable = true, table =
"PRODUCT_DETAILS")
+ public String getWareHouse() {
+ return wareHouse;
+ }
+
+ public void setWareHouse(String v) {
+ this.wareHouse = v;
+ }
+
+ @Embedded
+ @AttributeOverrides({
+ @AttributeOverride(name = "inceptionDate",
+ column = @Column(name = "INCEPTION", nullable = true)),
+ @AttributeOverride(name = "soldDate",
+ column = @Column(name = "SOLD", nullable = true))
+ })
+ public ShelfLife getShelfLife() {
+ return shelfLife;
+ }
+
+ public void setShelfLife(ShelfLife v) {
+ this.shelfLife = v;
+ }
+}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/ShelfLife.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/ShelfLife.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/ShelfLife.java 2009-12-16
22:12:45 UTC (rev 18250)
@@ -0,0 +1,60 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.ejb.metamodel;
+
+import java.sql.Date;
+import javax.persistence.Basic;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class ShelfLife implements java.io.Serializable {
+ private Date inceptionDate;
+ private Date soldDate;
+
+ public ShelfLife() {
+ }
+
+ public ShelfLife(Date inceptionDate, Date soldDate) {
+ this.inceptionDate = inceptionDate;
+ this.soldDate = soldDate;
+ }
+
+ @Basic
+ public Date getInceptionDate() {
+ return inceptionDate;
+ }
+
+ public void setInceptionDate(Date inceptionDate) {
+ this.inceptionDate = inceptionDate;
+ }
+
+ @Basic
+ public Date getSoldDate() {
+ return soldDate;
+ }
+
+ public void setSoldDate(Date soldDate) {
+ this.soldDate = soldDate;
+ }
+}