Author: hardy.ferentschik
Date: 2009-11-16 09:52:30 -0500 (Mon, 16 Nov 2009)
New Revision: 17992
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Dependent.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/DependentId.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Employee.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Employer.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/EmployerId.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/MedicalHistory.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Person.java
Log:
HHH-4529 Added some test entities
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Dependent.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Dependent.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Dependent.java 2009-11-16
14:52:30 UTC (rev 17992)
@@ -0,0 +1,57 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.test.annotations.derivedidentities;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+import javax.persistence.MapsId;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Dependent {
+ @EmbeddedId
+ DependentId id; // id attribute mapped by join column default
+
+ @MapsId("empPK") // maps empPK attribute of embedded id
+ @ManyToOne
+ Employee employee;
+
+ public Dependent() {
+ }
+
+ public Dependent(DependentId id) {
+ this.id = id;
+ }
+
+ public Employee getEmployee() {
+ return employee;
+ }
+
+ public void setEmployee(Employee employee) {
+ this.employee = employee;
+ }
+
+ public DependentId getId() {
+ return id;
+ }
+}
+
+
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/DependentId.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/DependentId.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/DependentId.java 2009-11-16
14:52:30 UTC (rev 17992)
@@ -0,0 +1,45 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.test.annotations.derivedidentities;
+
+import java.io.Serializable;
+import javax.persistence.Embeddable;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Embeddable
+public class DependentId implements Serializable {
+ String name;
+
+ long empPK; // corresponds to PK type of Employee
+
+ public DependentId() {
+ }
+
+ public DependentId(long empPK, String name) {
+ this.empPK = empPK;
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
+
+
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Employee.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Employee.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Employee.java 2009-11-16
14:52:30 UTC (rev 17992)
@@ -0,0 +1,39 @@
+// $Id:$
+package org.hibernate.test.annotations.derivedidentities;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Employee {
+ @Id
+ @GeneratedValue
+ long id;
+
+ String name;
+
+ public Employee() {
+ }
+
+ public Employee( String name) {
+ this.name = name;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+}
+
+
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Employer.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Employer.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Employer.java 2009-11-16
14:52:30 UTC (rev 17992)
@@ -0,0 +1,56 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.test.annotations.derivedidentities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.ManyToOne;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+(a)IdClass(EmployerId.class)
+public class Employer {
+ @Id
+ String name;
+
+ @Id
+ @ManyToOne
+ Employee employee;
+
+ public Employer() {
+ }
+
+ public Employer(String name) {
+ this.name = name;
+ }
+
+ public Employee getEmployee() {
+ return employee;
+ }
+
+ public void setEmployee(Employee emp) {
+ this.employee = emp;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
\ No newline at end of file
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/EmployerId.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/EmployerId.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/EmployerId.java 2009-11-16
14:52:30 UTC (rev 17992)
@@ -0,0 +1,43 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.test.annotations.derivedidentities;
+
+import java.io.Serializable;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class EmployerId implements Serializable {
+ String name; // matches name of @Id attribute
+ long employee; // matches name of @Id attribute and type of Employee PK
+
+ public EmployerId() {
+ }
+
+ public EmployerId(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setEmployee(long employee) {
+ this.employee = employee;
+ }
+}
\ No newline at end of file
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/MedicalHistory.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/MedicalHistory.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/MedicalHistory.java 2009-11-16
14:52:30 UTC (rev 17992)
@@ -0,0 +1,56 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.test.annotations.derivedidentities;
+
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.OneToOne;
+
+import org.hibernate.annotations.Entity;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class MedicalHistory {
+ @Id
+ @OneToOne
+ @JoinColumn(name="FK")
+ Person patient;
+
+ @Lob
+ byte[] xrayData;
+
+ private MedicalHistory() {
+ }
+
+ public MedicalHistory(Person patient) {
+ this.patient = patient;
+ }
+
+ public byte[] getXrayData() {
+ return xrayData;
+ }
+
+ public void setXrayData(byte[] xrayData) {
+ this.xrayData = xrayData;
+ }
+}
+
+
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Person.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Person.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/derivedidentities/Person.java 2009-11-16
14:52:30 UTC (rev 17992)
@@ -0,0 +1,43 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.test.annotations.derivedidentities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Person {
+ @Id
+ private String ssn;
+
+ private Person() {
+ }
+
+ public Person(String ssn) {
+ this.ssn = ssn;
+ }
+
+ public String getSsn() {
+ return ssn;
+ }
+}
+
+