HHH-9797 - Inaccurate warnings logged about duplicate joins (HHH000072)
This commit is contained in:
parent
df898f3fbc
commit
329e85b0b0
|
@ -1371,34 +1371,6 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector
|
||||||
return xrefEntry == null ? null : xrefEntry.secondaryTableJoinMap;
|
return xrefEntry == null ? null : xrefEntry.secondaryTableJoinMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addJoins(PersistentClass persistentClass, Map<String, Join> joins) {
|
|
||||||
// this part about resolving the super-EntityTableXref is a best effort. But
|
|
||||||
// really annotation binding is the only thing calling this, and it does not
|
|
||||||
// directly use the EntityTableXref stuff, so its all good.
|
|
||||||
final EntityTableXrefImpl superEntityTableXref;
|
|
||||||
if ( persistentClass.getSuperclass() == null ) {
|
|
||||||
superEntityTableXref = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
superEntityTableXref = entityTableXrefMap.get( persistentClass.getSuperclass().getEntityName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
final String primaryTableLogicalName = getLogicalTableName( persistentClass.getTable() );
|
|
||||||
final EntityTableXrefImpl xrefEntry = new EntityTableXrefImpl(
|
|
||||||
getDatabase().toIdentifier( primaryTableLogicalName ),
|
|
||||||
persistentClass.getTable(),
|
|
||||||
superEntityTableXref
|
|
||||||
);
|
|
||||||
|
|
||||||
final EntityTableXrefImpl old = entityTableXrefMap.put( persistentClass.getEntityName(), xrefEntry );
|
|
||||||
if ( old != null ) {
|
|
||||||
log.duplicateJoins( persistentClass.getEntityName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
xrefEntry.secondaryTableJoinMap = joins;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final class EntityTableXrefImpl implements EntityTableXref {
|
private final class EntityTableXrefImpl implements EntityTableXref {
|
||||||
private final Identifier primaryTableLogicalName;
|
private final Identifier primaryTableLogicalName;
|
||||||
private final Table primaryTable;
|
private final Table primaryTable;
|
||||||
|
|
|
@ -292,10 +292,10 @@ public interface InFlightMetadataCollector extends Mapping, MetadataImplementor
|
||||||
NaturalIdUniqueKeyBinder locateNaturalIdUniqueKeyBinder(String entityName);
|
NaturalIdUniqueKeyBinder locateNaturalIdUniqueKeyBinder(String entityName);
|
||||||
void registerNaturalIdUniqueKeyBinder(String entityName, NaturalIdUniqueKeyBinder ukBinder);
|
void registerNaturalIdUniqueKeyBinder(String entityName, NaturalIdUniqueKeyBinder ukBinder);
|
||||||
|
|
||||||
public static interface DelayedPropertyReferenceHandler extends Serializable {
|
interface DelayedPropertyReferenceHandler extends Serializable {
|
||||||
public void process(InFlightMetadataCollector metadataCollector);
|
void process(InFlightMetadataCollector metadataCollector);
|
||||||
}
|
}
|
||||||
public void addDelayedPropertyReferenceHandler(DelayedPropertyReferenceHandler handler);
|
void addDelayedPropertyReferenceHandler(DelayedPropertyReferenceHandler handler);
|
||||||
void addPropertyReference(String entityName, String propertyName);
|
void addPropertyReference(String entityName, String propertyName);
|
||||||
void addUniquePropertyReference(String entityName, String propertyName);
|
void addUniquePropertyReference(String entityName, String propertyName);
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ public interface InFlightMetadataCollector extends Mapping, MetadataImplementor
|
||||||
void addJpaIndexHolders(Table table, List<JPAIndexHolder> jpaIndexHolders);
|
void addJpaIndexHolders(Table table, List<JPAIndexHolder> jpaIndexHolders);
|
||||||
|
|
||||||
|
|
||||||
public static interface EntityTableXref {
|
interface EntityTableXref {
|
||||||
void addSecondaryTable(LocalMetadataBuildingContext buildingContext, Identifier logicalName, Join secondaryTableJoin);
|
void addSecondaryTable(LocalMetadataBuildingContext buildingContext, Identifier logicalName, Join secondaryTableJoin);
|
||||||
void addSecondaryTable(Identifier logicalName, Join secondaryTableJoin);
|
void addSecondaryTable(Identifier logicalName, Join secondaryTableJoin);
|
||||||
Table resolveTable(Identifier tableName);
|
Table resolveTable(Identifier tableName);
|
||||||
|
@ -318,7 +318,7 @@ public interface InFlightMetadataCollector extends Mapping, MetadataImplementor
|
||||||
Join locateJoin(Identifier tableName);
|
Join locateJoin(Identifier tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DuplicateSecondaryTableException extends HibernateException {
|
class DuplicateSecondaryTableException extends HibernateException {
|
||||||
private final Identifier tableName;
|
private final Identifier tableName;
|
||||||
|
|
||||||
public DuplicateSecondaryTableException(Identifier tableName) {
|
public DuplicateSecondaryTableException(Identifier tableName) {
|
||||||
|
@ -333,8 +333,11 @@ public interface InFlightMetadataCollector extends Mapping, MetadataImplementor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityTableXref getEntityTableXref(String entityName);
|
EntityTableXref getEntityTableXref(String entityName);
|
||||||
public EntityTableXref addEntityTableXref(String entityName, Identifier primaryTableLogicalName, Table primaryTable, EntityTableXref superEntityTableXref);
|
EntityTableXref addEntityTableXref(
|
||||||
void addJoins(PersistentClass persistentClass, Map<String, Join> secondaryTables);
|
String entityName,
|
||||||
|
Identifier primaryTableLogicalName,
|
||||||
|
Table primaryTable,
|
||||||
|
EntityTableXref superEntityTableXref);
|
||||||
Map<String,Join> getJoins(String entityName);
|
Map<String,Join> getJoins(String entityName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,8 @@ public class EntityBinder {
|
||||||
private boolean lazy;
|
private boolean lazy;
|
||||||
private XClass proxyClass;
|
private XClass proxyClass;
|
||||||
private String where;
|
private String where;
|
||||||
|
// todo : we should defer to InFlightMetadataCollector.EntityTableXref for secondary table tracking;
|
||||||
|
// atm we use both from here; HBM binding solely uses InFlightMetadataCollector.EntityTableXref
|
||||||
private java.util.Map<String, Join> secondaryTables = new HashMap<String, Join>();
|
private java.util.Map<String, Join> secondaryTables = new HashMap<String, Join>();
|
||||||
private java.util.Map<String, Object> secondaryTableJoins = new HashMap<String, Object>();
|
private java.util.Map<String, Object> secondaryTableJoins = new HashMap<String, Object>();
|
||||||
private String cacheConcurrentStrategy;
|
private String cacheConcurrentStrategy;
|
||||||
|
@ -698,7 +700,6 @@ public class EntityBinder {
|
||||||
Join join = (Join) joins.next();
|
Join join = (Join) joins.next();
|
||||||
createPrimaryColumnsToSecondaryTable( uncastedColumn, propertyHolder, join );
|
createPrimaryColumnsToSecondaryTable( uncastedColumn, propertyHolder, join );
|
||||||
}
|
}
|
||||||
context.getMetadataCollector().addJoins( persistentClass, secondaryTables );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPrimaryColumnsToSecondaryTable(Object uncastedColumn, PropertyHolder propertyHolder, Join join) {
|
private void createPrimaryColumnsToSecondaryTable(Object uncastedColumn, PropertyHolder propertyHolder, Join join) {
|
||||||
|
|
|
@ -1,35 +1,61 @@
|
||||||
//$Id: Customer.java 4364 2004-08-17 12:10:32Z oneovthafew $
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015, 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.test.join;
|
package org.hibernate.test.join;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.DiscriminatorValue;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.SecondaryTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@Entity
|
||||||
|
@DiscriminatorValue( "C" )
|
||||||
|
@SecondaryTable( name="customer" )
|
||||||
public class Customer extends Person {
|
public class Customer extends Person {
|
||||||
private Employee salesperson;
|
private Employee salesperson;
|
||||||
private String comments;
|
private String comments;
|
||||||
|
|
||||||
/**
|
@ManyToOne
|
||||||
* @return Returns the salesperson.
|
@JoinColumn( table = "customer" )
|
||||||
*/
|
|
||||||
public Employee getSalesperson() {
|
public Employee getSalesperson() {
|
||||||
return salesperson;
|
return salesperson;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param salesperson The salesperson to set.
|
|
||||||
*/
|
|
||||||
public void setSalesperson(Employee salesperson) {
|
public void setSalesperson(Employee salesperson) {
|
||||||
this.salesperson = salesperson;
|
this.salesperson = salesperson;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return Returns the comments.
|
@Column( table = "customer" )
|
||||||
*/
|
|
||||||
public String getComments() {
|
public String getComments() {
|
||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param comments The comments to set.
|
|
||||||
*/
|
|
||||||
public void setComments(String comments) {
|
public void setComments(String comments) {
|
||||||
this.comments = comments;
|
this.comments = comments;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +1,72 @@
|
||||||
//$Id: Employee.java 4364 2004-08-17 12:10:32Z oneovthafew $
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015, 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.test.join;
|
package org.hibernate.test.join;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.DiscriminatorValue;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.SecondaryTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@Entity
|
||||||
|
@DiscriminatorValue( "E" )
|
||||||
|
@SecondaryTable( name = "employee" )
|
||||||
public class Employee extends Person {
|
public class Employee extends Person {
|
||||||
private String title;
|
private String title;
|
||||||
private BigDecimal salary;
|
private BigDecimal salary;
|
||||||
private Employee manager;
|
private Employee manager;
|
||||||
/**
|
|
||||||
* @return Returns the title.
|
@Column( table = "employee", name = "`title`")
|
||||||
*/
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param title The title to set.
|
|
||||||
*/
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return Returns the manager.
|
@ManyToOne
|
||||||
*/
|
@JoinColumn( table = "employee" )
|
||||||
public Employee getManager() {
|
public Employee getManager() {
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param manager The manager to set.
|
|
||||||
*/
|
|
||||||
public void setManager(Employee manager) {
|
public void setManager(Employee manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return Returns the salary.
|
@Column( table = "employee" )
|
||||||
*/
|
|
||||||
public BigDecimal getSalary() {
|
public BigDecimal getSalary() {
|
||||||
return salary;
|
return salary;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param salary The salary to set.
|
|
||||||
*/
|
|
||||||
public void setSalary(BigDecimal salary) {
|
public void setSalary(BigDecimal salary) {
|
||||||
this.salary = salary;
|
this.salary = salary;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,54 @@
|
||||||
//$Id: Person.java 7203 2005-06-19 02:01:05Z oneovthafew $
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015, 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.test.join;
|
package org.hibernate.test.join;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.DiscriminatorColumn;
|
||||||
|
import javax.persistence.DiscriminatorValue;
|
||||||
|
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.PrimaryKeyJoinColumn;
|
||||||
|
import javax.persistence.SecondaryTable;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.ColumnTransformer;
|
||||||
|
import org.hibernate.annotations.Fetch;
|
||||||
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@Entity
|
||||||
|
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||||
|
@DiscriminatorColumn( name = "person_type" )
|
||||||
|
@DiscriminatorValue( value = "P" )
|
||||||
|
@SecondaryTable( name = "address", pkJoinColumns = @PrimaryKeyJoinColumn(name = "address_id") )
|
||||||
public class Person {
|
public class Person {
|
||||||
private long id;
|
private long id;
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -14,91 +57,73 @@ public class Person {
|
||||||
private String country;
|
private String country;
|
||||||
private double heightInches;
|
private double heightInches;
|
||||||
private char sex;
|
private char sex;
|
||||||
|
|
||||||
/**
|
@Id
|
||||||
* @return Returns the sex.
|
@GeneratedValue( generator = "increment" )
|
||||||
*/
|
@GenericGenerator( name = "increment", strategy = "increment" )
|
||||||
public char getSex() {
|
|
||||||
return sex;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param sex The sex to set.
|
|
||||||
*/
|
|
||||||
public void setSex(char sex) {
|
|
||||||
this.sex = sex;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return Returns the id.
|
|
||||||
*/
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param id The id to set.
|
|
||||||
*/
|
|
||||||
public void setId(long id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return Returns the identity.
|
public char getSex() {
|
||||||
*/
|
return sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSex(char sex) {
|
||||||
|
this.sex = sex;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param identity The identity to set.
|
|
||||||
*/
|
|
||||||
public void setName(String identity) {
|
public void setName(String identity) {
|
||||||
this.name = identity;
|
this.name = identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transient
|
||||||
public String getSpecies() {
|
public String getSpecies() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Column( name = "height_centimeters" )
|
||||||
* @return Returns the country.
|
@ColumnTransformer( read = "height_centimeters / 2.54E0", write = "? * 2.54E0" )
|
||||||
*/
|
|
||||||
public String getCountry() {
|
|
||||||
return country;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param country The country to set.
|
|
||||||
*/
|
|
||||||
public void setCountry(String country) {
|
|
||||||
this.country = country;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return Returns the zip.
|
|
||||||
*/
|
|
||||||
public String getZip() {
|
|
||||||
return zip;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param zip The zip to set.
|
|
||||||
*/
|
|
||||||
public void setZip(String zip) {
|
|
||||||
this.zip = zip;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return the The height in inches.
|
|
||||||
*/
|
|
||||||
public double getHeightInches() {
|
public double getHeightInches() {
|
||||||
return heightInches;
|
return heightInches;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param heightInches The height in inches.
|
|
||||||
*/
|
|
||||||
public void setHeightInches(double heightInches) {
|
public void setHeightInches(double heightInches) {
|
||||||
this.heightInches = heightInches;
|
this.heightInches = heightInches;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param address The address to set.
|
@Column(table = "address")
|
||||||
*/
|
|
||||||
public void setAddress(String address) {
|
|
||||||
this.address = address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(table = "address")
|
||||||
|
public String getCountry() {
|
||||||
|
return country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCountry(String country) {
|
||||||
|
this.country = country;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(table = "address")
|
||||||
|
public String getZip() {
|
||||||
|
return zip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZip(String zip) {
|
||||||
|
this.zip = zip;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015, 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.test.join;
|
||||||
|
|
||||||
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy of the model used in JoinTest, but using annotations rather than hbm.xml to look
|
||||||
|
* for the duplicate joins warning
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class SecondaryTableTest extends BaseCoreFunctionalTestCase {
|
||||||
|
@Override
|
||||||
|
public String[] getMappings() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
return new Class[] {Person.class, Employee.class, Customer.class, User.class};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIt() {
|
||||||
|
// really we have nothing to tes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,37 +1,76 @@
|
||||||
//$Id$
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015, 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.test.join;
|
package org.hibernate.test.join;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.DiscriminatorValue;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.SecondaryTable;
|
||||||
|
import javax.persistence.SecondaryTables;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.ColumnTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mike Dillon
|
* @author Mike Dillon
|
||||||
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@Entity
|
||||||
|
@DiscriminatorValue( "U" )
|
||||||
|
@SecondaryTables({
|
||||||
|
@SecondaryTable(name = "t_user"),
|
||||||
|
@SecondaryTable(name = "t_silly")
|
||||||
|
})
|
||||||
public class User extends Person {
|
public class User extends Person {
|
||||||
private String login;
|
private String login;
|
||||||
private String silly;
|
|
||||||
private Double passwordExpiryDays;
|
private Double passwordExpiryDays;
|
||||||
|
private String silly;
|
||||||
|
|
||||||
/**
|
@Column(table = "t_user", name = "u_login")
|
||||||
* @return Returns the login.
|
|
||||||
*/
|
|
||||||
public String getLogin() {
|
public String getLogin() {
|
||||||
return login;
|
return login;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param login The login to set.
|
|
||||||
*/
|
|
||||||
public void setLogin(String login) {
|
public void setLogin(String login) {
|
||||||
this.login = login;
|
this.login = login;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return The password expiry policy in days.
|
@Column(table = "t_user", name = "pwd_expiry_weeks")
|
||||||
*/
|
@ColumnTransformer( read = "pwd_expiry_weeks * 7.0E0", write = "? / 7.0E0")
|
||||||
public Double getPasswordExpiryDays() {
|
public Double getPasswordExpiryDays() {
|
||||||
return passwordExpiryDays;
|
return passwordExpiryDays;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param passwordExpiryDays The password expiry policy in days.
|
|
||||||
*/
|
|
||||||
public void setPasswordExpiryDays(Double passwordExpiryDays) {
|
public void setPasswordExpiryDays(Double passwordExpiryDays) {
|
||||||
this.passwordExpiryDays = passwordExpiryDays;
|
this.passwordExpiryDays = passwordExpiryDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Column(table = "t_silly")
|
||||||
|
public String getSilly() {
|
||||||
|
return silly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSilly(String silly) {
|
||||||
|
this.silly = silly;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue