[JIRA] (HHH-15990) unable to determine TableReference when associate ManyToOne fetch lazy and NotFound IGNORE: issue using Projection
by Andrea Boriero (JIRA)
Andrea Boriero ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HHH-15990 ( https://hibernate.atlassian.net/browse/HHH-15990?atlOrigin=eyJpIjoiY2MxYz... )
Re: unable to determine TableReference when associate ManyToOne fetch lazy and NotFound IGNORE: issue using Projection ( https://hibernate.atlassian.net/browse/HHH-15990?atlOrigin=eyJpIjoiY2MxYz... )
Hi BRUNO NUNES BORGES ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63b6c9d... )
I am trying to create a reproducer for the issue you reported but without any success, here is what I tried
@DomainModel(
annotatedClasses = {
NotFoundTest.Person.class,
NotFoundTest.Address.class,
}
)
@SessionFactory
public class NotFoundTest {
@BeforeAll
public void setUp(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
Address address = new Address( 1l, "Texas", "Austin" );
Person person = new Person( 2l, "And", address );
session.persist( address );
session.persist( person );
}
);
}
@Test
public void testIt(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
List<Address> addresses = session.createQuery(
"select a from Address a where a.state = :state",
Address.class
)
.setParameter( "state", "Texas" ).list();
assertThat( addresses.size() ).isEqualTo( 1 );
Address address = addresses.get( 0 );
assertThat( address.getPerson() ).isNotNull();
}
);
}
@Entity(name = "Address")
public static class Address {
@Id
private Long id;
@ManyToOne
@NotFound(action = NotFoundAction.IGNORE)
private Person person;
private String state;
private String city;
public Address() {
}
public Address(Long id, String state, String city) {
this.id = id;
this.state = state;
this.city = city;
}
public Long getId() {
return id;
}
public Person getPerson() {
return person;
}
public String getState() {
return state;
}
public String getCity() {
return city;
}
}
@Entity(name = "Person")
public static class Person {
@Id
private Long id;
private String name;
@ManyToOne
private Address address;
public Person() {
}
public Person(Long id, String name, Address address) {
this.id = id;
this.name = name;
this.address = address;
address.person = this;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public Address getAddress() {
return address;
}
}
}
am I missing something?
( https://hibernate.atlassian.net/browse/HHH-15990#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15990#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:06410ea )
1 year, 12 months