HHH-4529 Added some test entities
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17992 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
e20713b0f2
commit
546b13a7dd
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
@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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue