[JIRA] (HHH-16991) EnhancedUserType cannot be used when defining relations
by Timon Zilles (JIRA)
Timon Zilles ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HHH-16991 ( https://hibernate.atlassian.net/browse/HHH-16991?atlOrigin=eyJpIjoiY2VmZj... )
Re: EnhancedUserType cannot be used when defining relations ( https://hibernate.atlassian.net/browse/HHH-16991?atlOrigin=eyJpIjoiY2VmZj... )
Thank you for the fast response! 👍
I use an H2 database in my reproducer, but you are right. When adding
quarkus.hibernate-orm.fetch.batch-size=-1
in the application.properties file in order to deactive the batch loading (as a workaround), the error does not appear anymore.
But then the problem is, that now the relation objects are not loaded at all. When I access the getter method of the relation the select query is executed, but I don’t get any result.
*The query*
Hibernate:
select
e1_0.a_id,
e1_0.id
from
EntityB e1_0
where
e1_0.a_id=?
2023-07-26 10:18:08,264 TRACE [org.hib.orm.jdb.bind] (main) binding parameter [1] as [VARCHAR] - [org.acme.types.StringWrapper@49fb693d]
When I select the entities directly, it works as expected. So I assume, that the user type in general works.
*Example query (for my reproducer)*
public void findEntityAByField() {
final var qlString = "SELECT a FROM " + EntityA. class. getName() + " a WHERE a.id = :idField" ;
final var query = em.createQuery(qlString, EntityA.class);
query.setParameter( "idField" , new StringWrapper( "ID_A_001" ));
final var resultList = query.getResultList();
assertEquals(1, resultList.size());
}
The query looks like this
Hibernate:
select
e1_0.id
from
EntityA e1_0
where
e1_0.id=?
2023-07-26 10:18:08,452 TRACE [org.hib.orm.jdb.bind] (main) binding parameter [1] as [VARCHAR] - [org.acme.types.StringWrapper@5fe4848]
Here I get the entity as expected. As I said, because of this I think the user type works in general.
I created a new reproducer for this: https://github.com/timonzi/hibernate-user-type-for-relation-disabled-fetch
Am I missing something or is this (another) bug?
( https://hibernate.atlassian.net/browse/HHH-16991#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16991#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#100233- sha1:62cfdef )
2 years, 8 months