Move annotations.inheritance tests and implement qualifier omission for formulas in DML statements
This commit is contained in:
parent
f84585c5ed
commit
15f2dca36d
|
@ -215,6 +215,15 @@ public class SybaseASESqlAstTranslator<T extends JdbcOperation> extends Abstract
|
|||
&& roots.get( 0 ).getPrimaryTableReference() instanceof UnionTableReference ) {
|
||||
appendSql( columnReference.getExpressionText() );
|
||||
}
|
||||
// for now, use the unqualified form
|
||||
else if ( columnReference.isColumnExpressionFormula() ) {
|
||||
// For formulas, we have to replace the qualifier as the alias was already rendered into the formula
|
||||
// This is fine for now as this is only temporary anyway until we render aliases for table references
|
||||
appendSql(
|
||||
columnReference.getColumnExpression()
|
||||
.replaceAll( "(\\b)(" + getDmlTargetTableAlias() + "\\.)(\\b)", "$1$3" )
|
||||
);
|
||||
}
|
||||
else {
|
||||
appendSql( ( (MutationStatement) getStatement() ).getTargetTable().getTableExpression() );
|
||||
appendSql( '.' );
|
||||
|
|
|
@ -3471,7 +3471,17 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
|||
// or neither for its qualifier
|
||||
|
||||
// for now, use the unqualified form
|
||||
appendSql( columnReference.getColumnExpression() );
|
||||
if ( columnReference.isColumnExpressionFormula() ) {
|
||||
// For formulas, we have to replace the qualifier as the alias was already rendered into the formula
|
||||
// This is fine for now as this is only temporary anyway until we render aliases for table references
|
||||
appendSql(
|
||||
columnReference.getColumnExpression()
|
||||
.replaceAll( "(\\b)(" + dmlTargetTableAlias + "\\.)(\\b)", "$1$3" )
|
||||
);
|
||||
}
|
||||
else {
|
||||
appendSql( columnReference.getColumnExpression() );
|
||||
}
|
||||
}
|
||||
else {
|
||||
appendSql( columnReference.getExpressionText() );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.annotations.inheritance;
|
||||
package org.hibernate.orm.test.annotations.inheritance;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
|
@ -14,9 +14,9 @@ import org.hibernate.Session;
|
|||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.hibernate.test.annotations.inheritance.joined.Pool;
|
||||
import org.hibernate.test.annotations.inheritance.joined.PoolAddress;
|
||||
import org.hibernate.test.annotations.inheritance.joined.SwimmingPool;
|
||||
import org.hibernate.orm.test.annotations.inheritance.joined.Pool;
|
||||
import org.hibernate.orm.test.annotations.inheritance.joined.PoolAddress;
|
||||
import org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
Pool.class,
|
||||
org.hibernate.test.annotations.inheritance.joined.SwimmingPool.class
|
||||
org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool.class
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
|
@ -52,7 +52,7 @@ public class JoinedSubclassAndSecondaryTable {
|
|||
public void testSecondaryTableAndJoined(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
org.hibernate.test.annotations.inheritance.joined.SwimmingPool sp = new org.hibernate.test.annotations.inheritance.joined.SwimmingPool();
|
||||
org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool sp = new org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool();
|
||||
session.persist( sp );
|
||||
session.flush();
|
||||
session.clear();
|
||||
|
@ -72,17 +72,17 @@ public class JoinedSubclassAndSecondaryTable {
|
|||
"The address table is marked as optional. For null values no database row should be created"
|
||||
);
|
||||
|
||||
org.hibernate.test.annotations.inheritance.joined.SwimmingPool sp2 = session.get( org.hibernate.test.annotations.inheritance.joined.SwimmingPool.class, sp.getId() );
|
||||
org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool sp2 = session.get( org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool.class, sp.getId() );
|
||||
assertNull( sp.getAddress() );
|
||||
|
||||
org.hibernate.test.annotations.inheritance.joined.PoolAddress address = new org.hibernate.test.annotations.inheritance.joined.PoolAddress();
|
||||
org.hibernate.orm.test.annotations.inheritance.joined.PoolAddress address = new org.hibernate.orm.test.annotations.inheritance.joined.PoolAddress();
|
||||
address.setAddress( "Park Avenue" );
|
||||
sp2.setAddress( address );
|
||||
|
||||
session.flush();
|
||||
session.clear();
|
||||
|
||||
sp2 = session.get( org.hibernate.test.annotations.inheritance.joined.SwimmingPool.class, sp.getId() );
|
||||
sp2 = session.get( org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool.class, sp.getId() );
|
||||
// rowCount = getTableRowCount( session, "POOL_ADDRESS" );
|
||||
// assertEquals(
|
||||
//
|
||||
|
@ -107,7 +107,7 @@ public class JoinedSubclassAndSecondaryTable {
|
|||
public void testSecondaryTableAndJoinedInverse(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
org.hibernate.test.annotations.inheritance.joined.SwimmingPool sp = new org.hibernate.test.annotations.inheritance.joined.SwimmingPool();
|
||||
org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool sp = new org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool();
|
||||
session.persist( sp );
|
||||
session.flush();
|
||||
session.clear();
|
||||
|
@ -125,10 +125,10 @@ public class JoinedSubclassAndSecondaryTable {
|
|||
"The address table is marked as optional. For null values no database row should be created"
|
||||
);
|
||||
|
||||
org.hibernate.test.annotations.inheritance.joined.SwimmingPool sp2 = session.get( org.hibernate.test.annotations.inheritance.joined.SwimmingPool.class, sp.getId() );
|
||||
org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool sp2 = session.get( org.hibernate.orm.test.annotations.inheritance.joined.SwimmingPool.class, sp.getId() );
|
||||
assertNull( sp.getSecondaryAddress() );
|
||||
|
||||
org.hibernate.test.annotations.inheritance.joined.PoolAddress address = new PoolAddress();
|
||||
org.hibernate.orm.test.annotations.inheritance.joined.PoolAddress address = new PoolAddress();
|
||||
address.setAddress( "Park Avenue" );
|
||||
sp2.setSecondaryAddress( address );
|
||||
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "`ACCOUNT`")
|
||||
public class Account implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
@Column(name="fld_number")
|
||||
private String number;
|
||||
|
||||
@OneToMany(mappedBy="account")
|
||||
private Set<Client> clients;
|
||||
|
||||
private double balance;
|
||||
|
||||
public Account() {
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNumber() {
|
||||
return this.number;
|
||||
}
|
||||
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public double getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(double balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public void addClient(Client c) {
|
||||
if (clients == null) {
|
||||
clients = new HashSet<Client>();
|
||||
}
|
||||
clients.add(c);
|
||||
c.setAccount(this);
|
||||
}
|
||||
|
||||
|
||||
public Set<Client> getClients() {
|
||||
return clients;
|
||||
}
|
||||
|
||||
public void setClients(Set<Client> clients) {
|
||||
this.clients = clients;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinColumns;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorValue("AlarmT")
|
||||
public class Alarm extends EventInformation {
|
||||
|
||||
protected EventInformation eventInfo;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumns({@JoinColumn(name = "EVENTINFO_NOTIFICATIONID",
|
||||
referencedColumnName = "NOTIFICATIONID")})
|
||||
public EventInformation getEventInfo() {
|
||||
return eventInfo;
|
||||
}
|
||||
|
||||
public void setEventInfo(EventInformation value) {
|
||||
this.eventInfo = value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String eventId = ( getEventInfo() != null ?
|
||||
getEventInfo().getNotificationId() : null );
|
||||
sb.append(
|
||||
"AlarmT: id = " + getNotificationId() + "\t" +
|
||||
"has event id = " + eventId
|
||||
);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Table(name = "TBLASSET")
|
||||
public class Asset {
|
||||
private Integer id;
|
||||
|
||||
private Parent parent = null;
|
||||
|
||||
@Id @GeneratedValue public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ManyToOne(targetEntity = Parent.class)
|
||||
@JoinColumn(name = "PARENTID")
|
||||
public Parent getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(Parent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "CLIENT")
|
||||
public class Client extends Person implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String street;
|
||||
|
||||
private String code;
|
||||
|
||||
private String city;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "CLIENT_ACCOUNT",
|
||||
joinColumns = {@JoinColumn(name = "FK_CLIENT", referencedColumnName = "ID")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "FK_ACCOUNT", referencedColumnName = "ID")})
|
||||
private Account account;
|
||||
|
||||
public Account getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(Account account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Client() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
public abstract class Clothing {
|
||||
private long id;
|
||||
private int size;
|
||||
private String color;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "cloth_size")
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.SecondaryTable;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Sharath Reddy
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "Company")
|
||||
@SecondaryTable(name = "CompanyAddress")
|
||||
public class Company extends Customer {
|
||||
|
||||
private String companyName;
|
||||
private String companyAddress;
|
||||
|
||||
@Column
|
||||
public String getCompanyName() {
|
||||
return companyName;
|
||||
}
|
||||
|
||||
public void setCompanyName(String companyName) {
|
||||
this.companyName = companyName;
|
||||
}
|
||||
|
||||
@Column(table = "CompanyAddress")
|
||||
public String getCompanyAddress() {
|
||||
return companyAddress;
|
||||
}
|
||||
|
||||
public void setCompanyAddress(String companyAddress) {
|
||||
this.companyAddress = companyAddress;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.SecondaryTable;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Sharath Reddy
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Table(name = "Customer")
|
||||
@SecondaryTable(name = "CustomerDetails")
|
||||
public class Customer extends LegalEntity {
|
||||
|
||||
public String customerName;
|
||||
public String customerCode;
|
||||
|
||||
@Column
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String val) {
|
||||
this.customerName = val;
|
||||
}
|
||||
|
||||
@Column(table="CustomerDetails")
|
||||
public String getCustomerCode() {
|
||||
return customerCode;
|
||||
}
|
||||
|
||||
public void setCustomerCode(String val) {
|
||||
this.customerCode = val;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.hibernate.annotations.ForeignKey;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@ForeignKey(name = "FK_DOCU_FILE")
|
||||
public class Document extends File {
|
||||
@Column(nullable = false, name="xsize")
|
||||
private int size;
|
||||
|
||||
Document() {
|
||||
}
|
||||
|
||||
Document(String name, int size) {
|
||||
super( name );
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@DiscriminatorColumn(name = "DTYPE", discriminatorType = DiscriminatorType.STRING, length = 80)
|
||||
@DiscriminatorValue("EventInformationT")
|
||||
public class EventInformation implements java.io.Serializable {
|
||||
|
||||
|
||||
protected String notificationId;
|
||||
|
||||
@Id
|
||||
public String getNotificationId() {
|
||||
return notificationId;
|
||||
}
|
||||
|
||||
public void setNotificationId(String value) {
|
||||
this.notificationId = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( "EventInformationT: id = " + getNotificationId() );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Table(name="joined_file")
|
||||
public abstract class File {
|
||||
@Id @Column(name="filename")
|
||||
private String name;
|
||||
@ManyToOne
|
||||
private Folder parent;
|
||||
|
||||
File() {
|
||||
}
|
||||
|
||||
public File(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String id) {
|
||||
this.name = id;
|
||||
}
|
||||
|
||||
public Folder getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(Folder parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
public class FinancialAsset extends Asset {
|
||||
private double price;
|
||||
|
||||
public double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(double price) {
|
||||
this.price = price;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
public class Folder extends File {
|
||||
@OneToMany(mappedBy = "parent")
|
||||
private Set<File> children = new HashSet<File>();
|
||||
|
||||
Folder() {
|
||||
}
|
||||
|
||||
public Folder(String name) {
|
||||
super( name );
|
||||
}
|
||||
|
||||
public Set<File> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(Set children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
/**
|
||||
* @author Sharath Reddy
|
||||
*
|
||||
*/
|
||||
@MappedSuperclass
|
||||
public class LegalEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "Parent")
|
||||
public class Parent {
|
||||
private Integer id;
|
||||
private Set propertyAssets = new HashSet();
|
||||
private Set financialAssets = new HashSet();
|
||||
|
||||
@Id @GeneratedValue public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "parent", targetEntity = PropertyAsset.class)
|
||||
public Set getPropertyAssets() {
|
||||
return this.propertyAssets;
|
||||
}
|
||||
|
||||
public void setPropertyAssets(Set propertyAssets) {
|
||||
this.propertyAssets = propertyAssets;
|
||||
}
|
||||
|
||||
@OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "parent", targetEntity = FinancialAsset.class)
|
||||
public Set getFinancialAssets() {
|
||||
return this.financialAssets;
|
||||
}
|
||||
|
||||
public void setFinancialAssets(Set financialAssets) {
|
||||
this.financialAssets = financialAssets;
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Table(name = "PERSON")
|
||||
public class Person {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String firtsname;
|
||||
|
||||
public Person() {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firtsname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firtsname = firstname;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import org.hibernate.annotations.Tables;
|
||||
|
||||
import javax.persistence.AttributeOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.SecondaryTable;
|
||||
import javax.persistence.SecondaryTables;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@SecondaryTables({
|
||||
@SecondaryTable(name="POOL_ADDRESS"),
|
||||
@SecondaryTable(name="POOL_ADDRESS_2")
|
||||
})
|
||||
@Tables({
|
||||
@org.hibernate.annotations.Table(appliesTo="POOL_ADDRESS", optional=true),
|
||||
@org.hibernate.annotations.Table(appliesTo="POOL_ADDRESS_2", optional=true, inverse = true)
|
||||
})
|
||||
public class Pool {
|
||||
@Id @GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
@Embedded
|
||||
private PoolAddress address;
|
||||
|
||||
@Embedded
|
||||
@AttributeOverride(name = "address", column = @Column(table = "POOL_ADDRESS_2"))
|
||||
private PoolAddress secondaryAddress;
|
||||
|
||||
public PoolAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(PoolAddress address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public PoolAddress getSecondaryAddress() {
|
||||
return secondaryAddress;
|
||||
}
|
||||
|
||||
public void setSecondaryAddress(PoolAddress secondaryAddress) {
|
||||
this.secondaryAddress = secondaryAddress;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
@Embeddable
|
||||
public class PoolAddress {
|
||||
@Column(table = "POOL_ADDRESS")
|
||||
private String address;
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
public class ProgramExecution {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
private String action;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private File appliesOn;
|
||||
|
||||
|
||||
public File getAppliesOn() {
|
||||
return appliesOn;
|
||||
}
|
||||
|
||||
public void setAppliesOn(File appliesOn) {
|
||||
this.appliesOn = appliesOn;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
public class PropertyAsset extends Asset {
|
||||
private double price;
|
||||
|
||||
public double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(double price) {
|
||||
this.price = price;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@PrimaryKeyJoinColumn(name = "clothing_id")
|
||||
public class Sweater extends Clothing {
|
||||
private boolean isSweat;
|
||||
|
||||
public boolean isSweat() {
|
||||
return isSweat;
|
||||
}
|
||||
|
||||
public void setSweat(boolean sweat) {
|
||||
isSweat = sweat;
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
public class SwimmingPool extends Pool {
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.inheritance.joined;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class SymbolicLink extends File {
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
File target;
|
||||
|
||||
SymbolicLink() {
|
||||
}
|
||||
|
||||
public SymbolicLink(File target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public File getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(File target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue