-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: 5.2.10: @ManyToOne with enabled order_inserts wrong order
PostPosted: Wed Jul 05, 2017 8:23 am 
Newbie

Joined: Wed Jul 05, 2017 8:01 am
Posts: 1
Hi,
I'm aware of Bug https://hibernate.atlassian.net/browse/HHH-11585, which might be related and that was fixed in Hibernate 5.2.10. However, since upgrading to 5.2.10 from a 4.x project, I have trouble persisting entities with order-inserts enabled for batch-inserts. The insert-order is not correct.
Again: this worked like a charm with Hibernate 4.x

The entities:
Code:
@Entity
@Table(name = "LM_LIMITE")
public class LimitEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_LM_LIMITE")
    @SequenceGenerator(name = "SEQ_LM_LIMITE", sequenceName = "SEQ_LM_LIMITE", allocationSize = 1)
    @Column(name = "LIMIT_ID")
    private Long limitId;

   ...
}

and
Code:
@Entity
@Table(name = "LM_LIMIT_VERSIONEN")
public class LimitVersionEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_LM_LIMIT_VERSIONEN")
    @SequenceGenerator(name = "SEQ_LM_LIMIT_VERSIONEN", sequenceName = "SEQ_LM_LIMIT_VERSIONEN", allocationSize = 1)
    @Column(name = "EG_LIMIT_VERSION_ID")
    private Long id;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "EG_LIMIT_ID")
    private LimitEntity limitEntity;

    ...
}


In my code, I do something like this in a loop:

Code:
LimitEntity limit = new LimitEntity();
...

LimitVersionEntity version = new LimitVersionEntity();
version.setLimitEntity(limit);
...

entityManager.persist(limit);
entityManager.persist(version);

With order_inserts active, Hibernate now inserts the LimitVersionEntities before the LimitEntities. This leads to ConstraintViolations, as the foreign key constraint from table LM_LIMIT_VERSIONEN to LM_LIMITE cannot be fulfilled. With order_inserts deactivated, it works again, as well as if I flush immediately after persisting the LimitEntity.

I'm assuming this to be a bug, as it worked before. Can anyone confirm or give any advise?

Thank you!


Top
 Profile  
 
 Post subject: Re: 5.2.10: @ManyToOne with enabled order_inserts wrong order
PostPosted: Wed Jul 05, 2017 9:26 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Chek out the InsertOrderingWithManyToOne on GitHub. There are many more tests like this one for all the other associations and all of them work like a charm.

If you can come up with a replicating test case that fails, send a Pull Request so we can take a look on it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.