Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
James Howe
@OrangeDog
Oh right. That's not subqueries at all.
Are the foreign keys declared correctly?
Roy
@depzor
yes they are
I think the only solution to this is to use EntityGraphs
r_mohan
@r_mohan_twitter
I've been thinking of ways to avoid the N+1 query problem when I persist a child which doesn't have FK to its parent. The parent table is filled by events. So it can be refreshed. I use JPA.
When I update the child I need to check if the parent exists.
Steve Ebersole
@sebersole

Hi All, I have got a jpa entity with a
@ManyToOne on one of its properties, but it seems that for all my records an extra subquery is executed (n+1 issue). Is there any way to solve this? I tried to add: @Fetch(FetchMode.JOIN) but that didn't have any effect.
I want to force a join here instead of all those sub selects.

@depzor How do you trigger that "top" load?

Steve Ebersole
@sebersole
@r_mohan_twitter I mean what you describe is in fact exactly the point of Fks
if you don't want the database to do it, you are going to have to do it
the only way to verify that the order_number for a group of LineItems refers to a valid Order is to in fact verify the existence of that order_number in the orders table, e.g.
r_mohan
@r_mohan_twitter
@sebersole I will explain this. When an order is received into the the microservice I need to setup a pending payment record. The incoming event cannot have a FK link to payment because the incoming events can be rehydrated. They are not owned by payment. Using JPA's @JoinFormula I can pick up the latest payment for an order without a FK. Is it possible to setup a payment without a FK when the incoming order event is stored in a table ? I use PostgreSql. This could help avoid multiple queries and can help the first-level cache ? Not sure about this.
r_mohan
@r_mohan_twitter
Maybe a type of embeddable as the payment entity.
mstupo
@mstupo
Hi all, I hope that I'm on the right place and somebody will help me...
I'm using a second level cache (Hazelcast) to store entities and also collections (OneToMany mapping). After the update of the entity (JPA) the attributes of the entity self are updated in the cache, but the collection attribute (OneToMany) is not updated, but just evicted.
From my research, this is how the hibernate core is implemeted (core 5.4.25) - update of the entity does the real update (org.hibernate.action.internal.EntityUpdateAction), but update of the collection simply calls the evict() method (org.hibernate.action.internal.CollectionUpdateAction).
My question is: is this a normal behavior and I should live with that? Or is there a chance to configure something to do also the correct collections update instead of eviction?
Note: After the change of the entity and reloading it again (another call from client) the cache is rebuild correctly - entity is reloaded also with collections - I would need this updated state just after the entity update via JPA without a need to read it again from DB
Steve Ebersole
@sebersole

Is it possible to setup a payment without a FK when the incoming order event is stored in a table ?

@r_mohan_twitter You'd have to make the FK nullable, which is probably not accurate from your data model though only you know that. I mean you are simply enumerating the difficulties with handling FKs as not FKs

(worst editor ever)
Steve Ebersole
@sebersole
@mstupo You already found that this is the behavior.
nivinps
@nivinps

Hello all, I am using hibernate reactive framework for my spring webflux project. While saving new object, hibernate throws an exception if I used the entity id (primary key) as Integer. It will works fine if I used Long datatype. For us, in each table size will be less than 500000 records. So I choose Integer instead of Long. Please help.

Entity:

@Entity
@Table(name = "test_hibernate")
public class TestHibernateDBO {

@Id @GeneratedValue
@Column(name = "test_hibernate_id")
public Integer id;

@Column(name = "name")
public String name;

}

Exception message:

java.lang.IllegalArgumentException: Can not set java.lang.Integer field com.github.diegopacheco.sandboxspring.model.TestHibernateDBO.id to java.lang.Long

Steve Ebersole
@sebersole
@DavideD Any idea? ^^
@nivinps this chat is no longer really used by most of the developers as mentioned in the room subject. i just check every once in a while.
you will have much more luck using the preferred chat
Davide D'Alto
@DavideD
Checking
Davide D'Alto
@DavideD
@nivinps Which version of Hibernate REactive are you using?
Davide D'Alto
@DavideD
I can see the problem, I will create an issue for it
nivinps
@nivinps
@DavideD 1.0.0.Beta4
Davide D'Alto
@DavideD
I've created the issue here: hibernate/hibernate-reactive#609
I will try to fix it for the next release
nivinps
@nivinps
Thanks @DavideD for your support and thank you @sebersole
nivinps
@nivinps
I took latest update (1.0.0.CR1) from maven and the issue is resolved. thank you once again @DavideD @sebersole
NicklasWallgren
@NicklasWallgren

Hey, can anyone please explain why @LazyToOne(PROXY) eagerly loads singlar attributes, while @LazyToOne(NO_PROXY) doesn't?

I have tried to apply different LazyGroups, but once I change NO_PROXY to PROXY, the singular attributes are loaded anyway.

I have enabled enableLazyInitialization, enableDirtyTracking and enableAssociationManagement.

5 replies
NicklasWallgren
@NicklasWallgren
Are there any spatial dialects for mariadb?
Steve Ebersole
@sebersole
ok apparently i really cannot switch to compose mode. awesome gitter

Hey, can anyone please explain why @LazyToOne(PROXY) eagerly loads singlar attributes, while @LazyToOne(NO_PROXY) doesn't?

https://hibernate.atlassian.net/browse/HHH-14500 maybe?

Steve Ebersole
@sebersole
fwiw I am looking at that later this week
7 replies
antunonline
@antunonline
Hi!
I have a question related to JPA aggregations.
How can this be written with Hibernate?
select date, sum(delta)
from (select cat                 as category,
             ts::date            as date,
             max(val) - min(val) as delta
      from val_table
    where ts between ? and ?
      group by date,cat) as deltas
group by date
Steve Ebersole
@sebersole
you realize Hibernate is a JPA implementation, right?
I'm curious... do people even read the subject here and see that this is not the place to ask questions?
Maybe I need to make the subject even more explicit?
antunonline
@antunonline
Make it more explicit, write "Do not ask questions here".
Thanks!
Steve Ebersole
@sebersole
so the only thing I'm not sure about is ts::date. but that's not even JPA
is that trying to apply a "conversion" or something?
the only defined usage of : in JPA's query BNF is for defining named parameters
and even ? wont work
so not sure why you say this is a JPA query. its not
r_mohan
@r_mohan_twitter
It is able @Embeddable and I use JPA. I have a 'read' model for the UI. The 'write' to the history tables can happen separately. The query separation needs the 'read' model. I read that @Embeddables for the 'read' model have an advantage when a second-level cache is in effect. They are stored entirely in the cache( or something like that). Haven't verified it. Is this an advantage for a 'read' model for the UI ?
r_mohan
@r_mohan_twitter
Should I use @Embeddable for read and write ? These embeddable can be updated or inserted. Not deleted. And only the UI queries them for display. No other transactions involving them are needed.
Harikesh Pallantla
@harikesh409
can anyone tell me how to calculate percentage using CriteriaQuery
Mehmet
@mehmetcc
I have an entity A, mapped to entity B with bidirectional One-To-One association, and in the entity B there is a Set of Enums which I had coupled to B with @ElementCollection
This works for retrieving and inserting into the database, however deletion seems buggy that Hibernate somehow deletes entity A and the Set tables, but doesn't do anything about the B
Is this a bug or am I missing something?