HHH-13722 Introducing a test case
This commit is contained in:
parent
7331a58d5e
commit
be23e167af
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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.mapping.joinformula;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class ChildEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column(name = "PARENT_ID")
|
||||
private Long parentId;
|
||||
|
||||
@Column
|
||||
private String name;
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.mapping.joinformula;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
public class JoinFormulaTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
ParentEntity.class,
|
||||
ChildEntity.class
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Configuration configuration) {
|
||||
super.configure( configuration );
|
||||
configuration.setProperty( AvailableSettings.SHOW_SQL, Boolean.TRUE.toString() );
|
||||
configuration.setProperty( AvailableSettings.FORMAT_SQL, Boolean.TRUE.toString() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hhh13722Test() {
|
||||
try (Session s = openSession()) {
|
||||
//Nothing to do: the test just needs to verify that
|
||||
//this can boot.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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.mapping.joinformula;
|
||||
|
||||
import org.hibernate.annotations.JoinColumnOrFormula;
|
||||
import org.hibernate.annotations.JoinColumnsOrFormulas;
|
||||
import org.hibernate.annotations.JoinFormula;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class ParentEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@OneToOne(targetEntity = ChildEntity.class, optional = false)
|
||||
@JoinColumnsOrFormulas({
|
||||
@JoinColumnOrFormula(column = @JoinColumn(name = "ID", referencedColumnName = "PARENT_ID", insertable = false, updatable = false)),
|
||||
@JoinColumnOrFormula(formula = @JoinFormula(referencedColumnName = "NAME", value = "'Tom'"))
|
||||
})
|
||||
private ChildEntity tom;
|
||||
|
||||
@OneToOne(targetEntity = ChildEntity.class, optional = false)
|
||||
@JoinColumnsOrFormulas({
|
||||
@JoinColumnOrFormula(column = @JoinColumn(name = "ID", referencedColumnName = "PARENT_ID", insertable = false, updatable = false)),
|
||||
@JoinColumnOrFormula(formula = @JoinFormula(referencedColumnName = "NAME", value = "'Ben'"))
|
||||
})
|
||||
private ChildEntity ben;
|
||||
|
||||
}
|
Loading…
Reference in New Issue