This did not work as says it cannot find the partnumber field on CatalogHitCountObject, which is correct, it does not exist (and I messed up the query in the conversion).
The only solution I now find to get it working, is to create the partnumber field on the CatalogHitCountObject with the annotation
Thanks, but for both examples I get the same error:
Error: 1052-23000: Column ‘partnumber’ in field list is ambiguous
case #1
java.lang.Exception: Records Not Updated : org.hibernate.exception.ConstraintViolationException: JDBC exception executing SQL [update cataloghitcounts chcdo1_0 join catalog cd1_0 on cd1_0.partnumber=chcdo1_0.partnumber set partnumber=? where cd1_0.partnumber=?] [(conn=115) Column ‘partnumber’ in field list is ambiguous] [n/a]
case #2
java.lang.Exception: Records Not Updated : org.hibernate.exception.ConstraintViolationException: JDBC exception executing SQL [update cataloghitcounts chcdo1_0 join catalog cd1_0 on cd1_0.partnumber=chcdo1_0.partnumber set partnumber=? where chcdo1_0.partnumber=?] [(conn=115) Column ‘partnumber’ in field list is ambiguous] [n/a]
I am trying to update the CatalogHitCountObject partnumber
field, not the CatalogueObject partnumber field.
CatalogHitCountObject @Table(name = “cataloghitcounts”)
1 id Primary varchar(48)
2 partnumber Index varchar(48)
3 username Index varchar(255)
This is a bug. Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.
Well my Jira ticket got closed. I did some more testing and it does work in the producer.
On my system I get this for the query:
query = “update HitCount c set c.catalogue.id=:newPartnumber where c.catalogue.id=:partnumber”;
Hibernate:
update
cataloghitcounts chcdo1_0
join
catalogue cd1_0
on cd1_0.partnumber=chcdo1_0.partnumber
set
partnumber=?
where
cd1_0.partnumber=?
[ WARN] (ajp-nio-127.0.0.1-8009-exec-6) Error: 1052-23000: Column ‘partnumber’ in field list is ambiguous
========
The producer for the query:
query = “update HitCount set catalogue.id=:newPartnumber where catalogue.id=:partnumber”;
Hibernate:
merge
into
HitCount as t
using (
select
cast(? as varchar),
hc1_0._rowid_ from
HitCount hc1_0
join
Catalogue c1_0
on c1_0.partNumber=hc1_0.partNumber
where
c1_0.partNumber=?
) s(c0, c1)
on t._rowid_=s.c1
when matched
then update set
t.partNumber=s.c0
The fact that the queries are different had me concerned.
The producer is jakarta.persistence.EntityManagerFactory whilst we are using org.hibernate.SessionFactory via spring: org.springframework.orm.hibernate5.LocalSessionFactoryBean.
Reading up, the spring hibernate5 classes should be migrated to JPA style configs but I cannot find much info on how to do this migration.
I would have thought by now this would be a well trodden path.
The jakarta.persistence package contains just interfaces, Hibernate ORM is the implementation. You can code against these interfaces if you want, since that is more “portable”, but you can also stick to Hibernate ORM classes directly if you prefer and want to leverage Hibernate specific features.