HHH-4895 query against derived id doesn't return expected result
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18747 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
cb63cbb2ab
commit
f0cdfa3ac8
|
@ -4,6 +4,8 @@ import org.hibernate.Session;
|
|||
import org.hibernate.test.annotations.TestCase;
|
||||
import org.hibernate.test.util.SchemaUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
|
@ -35,6 +37,31 @@ public class DerivedIdentitySimpleParentIdClassDepTest extends TestCase {
|
|||
s.close();
|
||||
}
|
||||
|
||||
public void testQueryNewEntityInPC() throws Exception {
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
Employee e = new Employee( 1L, "Paula", "P" );
|
||||
Dependent d = new Dependent( "LittleP", e );
|
||||
d.setEmp(e);
|
||||
s.persist( d );
|
||||
s.persist( e );
|
||||
|
||||
// the following would work
|
||||
// List depList = s.createQuery("Select d from Dependent d where d.name='LittleP'").list();
|
||||
|
||||
// the following query is not finding the entity 'd' added above
|
||||
List depList = s.createQuery("Select d from Dependent d where d.name='LittleP' and d.emp.name='Paula'").list();
|
||||
Object newDependent = null;
|
||||
if (depList.size() > 0) {
|
||||
newDependent = (Dependent) depList.get(0);
|
||||
}
|
||||
if (newDependent != d) {
|
||||
fail("PC entity instance (" + d +") does not match returned query result value (" + newDependent);
|
||||
}
|
||||
s.getTransaction().rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
|
|
Loading…
Reference in New Issue