[hibernate-dev] please close HHH-13939
It was a failure of finding the documentation between 4.x and 5.x with regards to @GeneratedValue(AUTO) behavior. Setting hibernate.id.new_generator_mappings=false fixed it. v/r, Jason ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
[hibernate-dev] https://hibernate.atlassian.net/browse/HHH-9798 Unique constraint / not null of @JoinTable for @OneToOne not generated
I think I have found another corner case on the https://hibernate.atlassian.net/browse/HHH-9798 regression. The cited example is: @OneToOne(fetch = FetchType.LAZY) @JoinTable( name = "ITEM_SHIPMENT", // Required! joinColumns = @JoinColumn(name = "SHIPMENT_ID"), // Defaults to ID inverseJoinColumns = @JoinColumn(name = "ITEM_ID", // Defaults to AUCTION_ID nullable = false, unique = true) ) protected Item auction; but an equally similar case ought to be: @OneToOne(fetch = FetchType.LAZY) @JoinTable( name = "ITEM_SHIPMENT", // Required! ) protected Item auction; The rationale here is that a @JoinTable is used to “not have the null rows” that would be present if a @JoinColumn was to be used on an @OneToOne(optional=true). I cannot find in the spec where this is implied, required, or excluded. Otherwise one would have to say: @OneToOne(fetch = FetchType.LAZY) @JoinTable( name = "ITEM_SHIPMENT", // Required! inverseJoinColumns = @JoinColumn(nullable = false, unique = true) ) protected Item auction; Thoughts? -Jason ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] https://hibernate.atlassian.net/browse/HHH-9798 Unique constraint / not null of @JoinTable for @OneToOne not generated
> -Original Message- > From: Jason Pyeron > Sent: Sunday, April 19, 2020 11:20 AM > > I think I have found another corner case on the > https://hibernate.atlassian.net/browse/HHH-9798 regression. > > > > > > @OneToOne(fetch = FetchType.LAZY) > > @JoinTable( > > name = "ITEM_SHIPMENT", // Required! > > inverseJoinColumns = > > @JoinColumn(nullable = false, Adding the nullable =false is correctly generating the join table with a not null, but is implying a optional=false on the OneToOne... javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value : .auction > > unique = true) > > ) > > protected Item auction; > > > > Thoughts? > > -Jason ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
[hibernate-dev] HHH-13959 - OneToOne JoinTable with unique constraints work around?
https://hibernate.atlassian.net/browse/HHH-13959 I started a DB migration today, now we are dead in the water due to this exception. When I persist an Entity on the owning side of the OneToOne(optional=true) relationship, and that property is null we are getting: javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value I am looking to where I can patch Hibernate or put a workaround in our code. Any help? -Jason ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] HHH-13959 - OneToOne JoinTable with unique constraints work around?
SessionFactoryImpl.(MetadataImplementor, SessionFactoryOptions) line: 299 SessionFactoryBuilderImpl.build() line: 468 EntityManagerFactoryBuilderImpl.build() line: 1249 HibernatePersistenceProvider.createEntityManagerFactory(String, Map) line: 56 Persistence.createEntityManagerFactory(String, Map) line: 79 Persistence.createEntityManagerFactory(String) line: 54 JPAUnitTestCase.init() line: 27 3: Nullability.checkNullability(Object[], EntityPersister, Nullability$NullabilityCheckType) line: 92 Nullability.checkNullability(Object[], EntityPersister, boolean) line: 55 EntityIdentityInsertAction(AbstractEntityInsertAction).nullifyTransientReferencesIfNotAlready() line: 116 EntityIdentityInsertAction(AbstractEntityInsertAction).makeEntityManaged() line: 125 ActionQueue.addResolvedEntityInsertAction(AbstractEntityInsertAction) line: 289 ActionQueue.addInsertAction(AbstractEntityInsertAction) line: 263 ActionQueue.addAction(EntityIdentityInsertAction) line: 317 DefaultPersistEventListener(AbstractSaveEventListener).addInsertAction(Object[], Serializable, Object, EntityPersister, boolean, EventSource, boolean) line: 330 DefaultPersistEventListener(AbstractSaveEventListener).performSaveOrReplicate(Object, EntityKey, EntityPersister, boolean, Object, EventSource, boolean) line: 287 DefaultPersistEventListener(AbstractSaveEventListener).performSave(Object, Serializable, EntityPersister, boolean, Object, EventSource, boolean) line: 193 DefaultPersistEventListener(AbstractSaveEventListener).saveWithGeneratedId(Object, String, Object, EventSource, boolean) line: 123 DefaultPersistEventListener.entityIsTransient(PersistEvent, Map) line: 185 DefaultPersistEventListener.onPersist(PersistEvent, Map) line: 128 DefaultPersistEventListener.onPersist(PersistEvent) line: 55 1021082377.accept(Object, Object) line: not available EventListenerGroupImpl.fireEventOnEachListener(U, BiConsumer) line: 102 SessionImpl.firePersist(PersistEvent) line: 710 SessionImpl.persist(Object) line: 696 JPAUnitTestCase.hhh13959TestProfile() line: 43 > -Original Message- > From: hibernate-dev-boun...@lists.jboss.org > [mailto:hibernate-dev-boun...@lists.jboss.org] > On Behalf Of Jason Pyeron > Sent: Sunday, April 19, 2020 11:18 PM > To: hibernate-us...@lists.jboss.org; hibernate-dev@lists.jboss.org > Subject: [hibernate-dev] HHH-13959 - OneToOne JoinTable with unique > constraints work > around? > > https://hibernate.atlassian.net/browse/HHH-13959 > > > > I started a DB migration today, now we are dead in the water due to this > exception. > > > > When I persist an Entity on the owning side of the OneToOne(optional=true) > relationship, > and that property is null we are getting: > > > > javax.persistence.PersistenceException: org.hibernate.PropertyValueException: > not-null > property references a null or transient value > > > > I am looking to where I can patch Hibernate or put a workaround in our code. > > > > Any help? > > > > -Jason > > ___ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] HHH-13959 - OneToOne JoinTable with unique constraints work around?
[oops, did not mean to post the code to users] I have narrowed it down, and I think these changes will address the issue. commit 6ffdc4d684b33777b1c483473444d25b642e0748 (HEAD -> HHH-13959, pdinc-oss/HHH-13959) Author: Jason Pyeron Date: Mon Apr 20 02:20:21 2020 -0400 HHH-13959 Added optional awareness to FK driven OneToOne mappings * PropertyBinder needed optional awareness, null means don't change/set it diff --git a/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/AnnotationBinder.java b/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/AnnotationBinder.java index eec3b49..392b8c6 100644 --- a/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/AnnotationBinder.java +++ b/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/AnnotationBinder.java @@ -3240,6 +3240,7 @@ public final class AnnotationBinder { } else { //has a FK on the table + propertyBinder.setOptional(optional); bindManyToOne( cascadeStrategy, joinColumns, optional, ignoreNotFound, cascadeOnDelete, targetEntity, diff --git a/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/annotations/PropertyBinder.java b/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/annotations/PropertyBinder.java index 83c3f0c..e30946d 100644 --- a/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/annotations/PropertyBinder.java +++ b/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/annotations/PropertyBinder.java @@ -74,6 +74,17 @@ public class PropertyBinder { private EntityBinder entityBinder; private boolean isXToMany; private String referencedEntityName; + private Boolean optional; + + public Boolean isOptional() + { + return optional; + } + + public void setOptional(Boolean optional) + { + this.optional = optional; + } public void setReferencedEntityName(String referencedEntityName) { this.referencedEntityName = referencedEntityName; @@ -328,6 +339,12 @@ public class PropertyBinder { LOG.tracev( "Cascading {0} with {1}", name, cascade ); this.mappingProperty = prop; + + if (optional != null) + { + prop.setOptional(optional); + } + return prop; } -Jason > -Original Message- > From: hibernate-dev-boun...@lists.jboss.org > [mailto:hibernate-dev-boun...@lists.jboss.org] > On Behalf Of Jason Pyeron > Sent: Monday, April 20, 2020 1:12 AM > To: hibernate-us...@lists.jboss.org; hibernate-dev@lists.jboss.org > Subject: Re: [hibernate-dev] HHH-13959 - OneToOne JoinTable with unique > constraints work > around? > > [pardon the top post, it did not mix in well] > > It looks like [stack trace 1] the option is never set in this situation, > because the only > place it is set is when > > if ( trueOneToOne || mapToPK || > !BinderHelper.isEmptyAnnotationValue( mappedBy ) > ) { > > but since there is a FK involved it is running > > //has a FK on the table > bindManyToOne( > cascadeStrategy, joinColumns, optional, > ignoreNotFound, > cascadeOnDelete, > targetEntity, > propertyHolder, inferredData, true, > isIdentifierMapper, > inSecondPass, > propertyBinder, context > ); > > Debugging shows the optional==true. Looking at that method, the only use of > optional > parameter is > > if ( !optional ) { > for ( Ejb3JoinColumn column : columns ) { > column.setNullable( false ); > } > } > > Which is not relevant, since optional is true. That is the last line of code > in > bindOneToOne(...) > > Now when the evaluation of the properties are being made to persist in the > EntityMetamodel > [stack trace 2] the optional is false. As a consequence the > checkNullability(...) will > fail with a PropertyValueException during the nullability check [stack trace > 3]: > > if ( !nullability[i] && value == null ) { > //check basic level one > nullablilty > throw new > PropertyValueException( > "not-null > property references a nu
Re: [hibernate-dev] HHH-13959 - OneToOne JoinTable with unique constraints work around?
cuteUpdate(JdbcPreparedStatement.java:150) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197) ... 28 more > -Original Message- > From: hibernate-dev-boun...@lists.jboss.org > [mailto:hibernate-dev-boun...@lists.jboss.org] > On Behalf Of Jason Pyeron > Sent: Monday, April 20, 2020 2:25 AM > To: hibernate-dev@lists.jboss.org > Subject: Re: [hibernate-dev] HHH-13959 - OneToOne JoinTable with unique > constraints work > around? > > [oops, did not mean to post the code to users] > > I have narrowed it down, and I think these changes will address the issue. > > commit 6ffdc4d684b33777b1c483473444d25b642e0748 (HEAD -> HHH-13959, > pdinc-oss/HHH-13959) > Author: Jason Pyeron > Date: Mon Apr 20 02:20:21 2020 -0400 > > HHH-13959 Added optional awareness to FK driven OneToOne mappings > > * PropertyBinder needed optional awareness, null means don't change/set it > > diff --git > a/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/AnnotationBinder.java > b/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/AnnotationBinder.java > index eec3b49..392b8c6 100644 > --- > a/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/AnnotationBinder.java > +++ > b/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/AnnotationBinder.java > @@ -3240,6 +3240,7 @@ public final class AnnotationBinder { > } > else { > //has a FK on the table > + propertyBinder.setOptional(optional); > bindManyToOne( > cascadeStrategy, joinColumns, > optional, > ignoreNotFound, cascadeOnDelete, > targetEntity, > diff --git a/orm/hibernate-orm- > 5/src/test/java/org/hibernate/cfg/annotations/PropertyBinder.java > b/orm/hibernate-orm- > 5/src/test/java/org/hibernate/cfg/annotations/PropertyBinder.java > index 83c3f0c..e30946d 100644 > --- > a/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/annotations/PropertyBinder.java > +++ > b/orm/hibernate-orm-5/src/test/java/org/hibernate/cfg/annotations/PropertyBinder.java > @@ -74,6 +74,17 @@ public class PropertyBinder { > private EntityBinder entityBinder; > private boolean isXToMany; > private String referencedEntityName; > + private Boolean optional; > + > + public Boolean isOptional() > + { > + return optional; > + } > + > + public void setOptional(Boolean optional) > + { > + this.optional = optional; > + } > > public void setReferencedEntityName(String referencedEntityName) { > this.referencedEntityName = referencedEntityName; > @@ -328,6 +339,12 @@ public class PropertyBinder { > > LOG.tracev( "Cascading {0} with {1}", name, cascade ); > this.mappingProperty = prop; > + > + if (optional != null) > + { > + prop.setOptional(optional); > + } > + > return prop; > } > > -Jason > > > -Original Message- > > From: hibernate-dev-boun...@lists.jboss.org [mailto:hibernate-dev- > boun...@lists.jboss.org] > > On Behalf Of Jason Pyeron > > Sent: Monday, April 20, 2020 1:12 AM > > To: hibernate-us...@lists.jboss.org; hibernate-dev@lists.jboss.org > > Subject: Re: [hibernate-dev] HHH-13959 - OneToOne JoinTable with unique > > constraints work > > around? > > > > [pardon the top post, it did not mix in well] > > > > It looks like [stack trace 1] the option is never set in this situation, > > because the > only > > place it is set is when > > > > if ( trueOneToOne || mapToPK || > > !BinderHelper.isEmptyAnnotationValue( mappedBy ) > > ) { > > > > but since there is a FK involved it is running > > > > //has a FK on the table > > bindManyToOne( > > cascadeStrategy, joinColumns, optional, > > ignoreNotFound, > > cascadeOnDelete, > > targetEntity, > > propertyHolder, inferredData, true, > > isIdentifierMapper, > > inSecondPass, > > propertyBinder, context > > ); > > > > Debugging shows the optional==true. Looking at that method, the only use of > > optional > > parameter is > > > > if ( !
[hibernate-dev] HHH-11699 Hibernate ignores 'schema' attribute of @SequenceGenerator for Oracle --- and SQL Server --- sequences
The issue is impacting current releases for both schema generation and runtime use. I do not have permissions to update the title/summary. -Jason ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] HHH-11699 Hibernate ignores 'schema' attribute of @SequenceGenerator for Oracle --- and SQL Server --- sequences
Sorry, accidentally sent to Andrea and not the list. From: Jason Pyeron [mailto:jpye...@pdinc.us] Sent: Tuesday, April 21, 2020 8:56 AM To: 'andrea boriero' Subject: RE: [hibernate-dev] HHH-11699 Hibernate ignores 'schema' attribute of @SequenceGenerator for Oracle --- and SQL Server --- sequences That then conflicts with HHH-13939. Either way, no joy. Lastly, it should not have an effect on definitions like: @Id @Column(name = "sid") @GeneratedValue(generator = "SIGNATURE", strategy = GenerationType.SEQUENCE) @SequenceGenerator(name = "SIGNATURE", schema = "cresaptown", sequenceName = "signature_seq") Long sid; -Jason From: andrea boriero [mailto:and...@hibernate.org] Sent: Tuesday, April 21, 2020 3:07 AM To: Jason Pyeron mailto:jpye...@pdinc.us> > Subject: Re: [hibernate-dev] HHH-11699 Hibernate ignores 'schema' attribute of @SequenceGenerator for Oracle --- and SQL Server --- sequences Hi Jason, in the Jira I explained that the issue seems related to Spring setting the `hibernate.id.new_generator_mappings` value to false. Have you tried to explicitly change this value to true? Cheers, Andrea On Tue, 21 Apr 2020 at 03:57, Jason Pyeron mailto:jpye...@pdinc.us> > wrote: The issue is impacting current releases for both schema generation and runtime use. I do not have permissions to update the title/summary. -Jason ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org <mailto:hibernate-dev@lists.jboss.org> https://lists.jboss.org/mailman/listinfo/hibernate-dev ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier generation - No part of a composite identifier may be null HibernateException
Turns out this issue may be a duplicate of a known issue, taking this over to the dev list. org/hibernate/test/annotations/cid/CompositeIdIdentityTest.java: 7 package org.hibernate.test.annotations.cid; 48 @RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class) 49 @TestForIssue( jiraKey = "HHH-9662" ) 50 public class CompositeIdIdentityTest extends BaseCoreFunctionalTestCase { 51 52 @Test 53 @FailureExpected( jiraKey = "HHH-9662" ) 54 public void testCompositePkWithIdentity() throws Exception { 55 doInHibernate( this::sessionFactory, session -> { 56 Animal animal = new Animal(); 57 animal.setSubId( 123L ); 58 session.persist(animal); 59 } ); 60 } 61 70 @Entity 71 @Table(name = "animal") 72 @IdClass(IdWithSubId.class) 73 public static class Animal { 74 75 @Id 76 @GeneratedValue(strategy = GenerationType.IDENTITY) 77 private Long id; 78 79 @Id 80 @Column(name = "sub_id") 81 private Long subId; 82 From: Jason Pyeron [mailto:jpye...@pdinc.us] Sent: Tuesday, April 21, 2020 1:32 AM To: 'hibernate-us...@lists.jboss.org' Subject: HHH-6044 and partial identifier generation - No part of a composite identifier may be null HibernateException [note this is an issue with sequences too] Quoting https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#identifiers-composite-nonaggregated With non-aggregated composite identifiers, Hibernate also supports "partial" generation of the composite values. Example 135. @IdClass with partial identifier generation using @GeneratedValue I seem to be having the same issues as https://hibernate.atlassian.net/browse/HHH-6044 I have existing tables / Entities (simplified): CREATE TABLE [cresaptown].[saar]( [id] [bigint] IDENTITY(1,1) NOT NULL primary key ); @Entity @Table(schema = "cresaptown", name = "saar") public class SystemAccessAuthorizationRequest { @Id @GeneratedValue Long id; } CREATE TABLE [cresaptown].[signature]( [rid] [bigint] IDENTITY(1,1) NOT NULL, [sid] [bigint] NOT NULL, PRIMARY KEY ([rid],[sid]), FOREIGN KEY([rid]) REFERENCES [cresaptown].[saar] ([id]) ); @Entity @Table(schema = "cresaptown", name = "signature") @IdClass(Signature.ID.class) public class Signature { @Id @Column(name = "sid") @GeneratedValue Long sid; @Id @JoinColumn(name = "rid") @ManyToOne SystemAccessAuthorizationRequest rid; public static class ID implements Serializable { Long sid; Long rid; } } A code fragment em.getTransaction().begin(); SystemAccessAuthorizationRequest saar = new SystemAccessAuthorizationRequest(); em.persist(saar); Signature sig = new Signature(); sig.setRid(saar); em.persist(sig); em.getTransaction().commit(); gives this exception, but if I disable the null check in AbstractEntityTuplizer.getIdentifier, I get the same issue as in HHH-6044 javax.persistence.PersistenceException: org.hibernate.HibernateException: No part of a composite identifier may be null at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:716) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:696) at x.Testclass.x(Testclass.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild
Re: [hibernate-dev] HHH-11699 Hibernate ignores 'schema' attribute of @SequenceGenerator for Oracle --- and SQL Server --- sequences
I cleaned up the test case. My miss report of failure on the setting of false was due to other consequences of setting it to false (e.g. HHH-13939). It does in fact create and use the correct schema when hibernate.id.new_generator_mappings=false . This does not feel like a fix, quoting https://docs.jboss.org/hibernate/stable/annotations/reference/en/html/ch01.html "We recommend all new projects to use hibernate.id.new_generator_mappings=true ... However they are not backward compatible with existing databases ..." -Jason > -Original Message- > From: hibernate-dev-boun...@lists.jboss.org > [mailto:hibernate-dev-boun...@lists.jboss.org] > On Behalf Of Jason Pyeron > Sent: Tuesday, April 21, 2020 8:58 AM > To: hibernate-dev@lists.jboss.org > Subject: Re: [hibernate-dev] HHH-11699 Hibernate ignores 'schema' attribute of > @SequenceGenerator for Oracle --- and SQL Server --- sequences > > Sorry, accidentally sent to Andrea and not the list. > > > > From: Jason Pyeron [mailto:jpye...@pdinc.us] > Sent: Tuesday, April 21, 2020 8:56 AM > To: 'andrea boriero' > Subject: RE: [hibernate-dev] HHH-11699 Hibernate ignores 'schema' attribute of > @SequenceGenerator for Oracle --- and SQL Server --- sequences > > > > That then conflicts with HHH-13939. > > > > Either way, no joy. Lastly, it should not have an effect on definitions like: > > > > @Id > > @Column(name = "sid") > > @GeneratedValue(generator = "SIGNATURE", strategy = > GenerationType.SEQUENCE) > > @SequenceGenerator(name = "SIGNATURE", schema = "cresaptown", > sequenceName = > "signature_seq") > > Long sid; > > > > -Jason > > > > From: andrea boriero [mailto:and...@hibernate.org] > Sent: Tuesday, April 21, 2020 3:07 AM > To: Jason Pyeron mailto:jpye...@pdinc.us> > > Subject: Re: [hibernate-dev] HHH-11699 Hibernate ignores 'schema' attribute of > @SequenceGenerator for Oracle --- and SQL Server --- sequences > > > > Hi Jason, > > > > in the Jira I explained that the issue seems related to Spring setting the > `hibernate.id.new_generator_mappings` value to false. > > Have you tried to explicitly change this value to true? > > > > Cheers, > > > > Andrea > > > > On Tue, 21 Apr 2020 at 03:57, Jason Pyeron <mailto:jpye...@pdinc.us> > > wrote: > > The issue is impacting current releases for both schema generation and > runtime use. > > > > I do not have permissions to update the title/summary. > > > > -Jason > > ___ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org <mailto:hibernate-dev@lists.jboss.org> > https://lists.jboss.org/mailman/listinfo/hibernate-dev > > ___ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier generation - No part of a composite identifier may be null HibernateException
How can I help on HHH-9662 ? I have found that this fails with sequences too, when the composite identifier is another entity. This works: @Id @Column(name = "registration_number") @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long registrationNumber; @Id @Column(name = "publisher_id") private Integer publisherId; but, this does not: @Id @Column(name = "registration_number") @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long registrationNumber; @Id @JoinColumn(name = "publisher_id") @ManyToOne private Publisher publisherId; -Jason > -Original Message- > From: hibernate-dev-boun...@lists.jboss.org > [mailto:hibernate-dev-boun...@lists.jboss.org] > On Behalf Of Jason Pyeron > Sent: Tuesday, April 21, 2020 9:23 AM > To: hibernate-us...@lists.jboss.org; hibernate-dev@lists.jboss.org > Subject: Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier > generation - No > part of a composite identifier may be null HibernateException > > Turns out this issue may be a duplicate of a known issue, taking this over to > the dev > list. > > > > org/hibernate/test/annotations/cid/CompositeIdIdentityTest.java: > > 7 package org.hibernate.test.annotations.cid; > > 48 @RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class) > > 49 @TestForIssue( jiraKey = "HHH-9662" ) > > 50 public class CompositeIdIdentityTest extends > BaseCoreFunctionalTestCase { > > 51 > > 52 @Test > > 53 @FailureExpected( jiraKey = "HHH-9662" ) > > 54 public void testCompositePkWithIdentity() throws Exception { > > 55 doInHibernate( this::sessionFactory, session -> { > > 56 Animal animal = new Animal(); > > 57 animal.setSubId( 123L ); > > 58 session.persist(animal); > > 59 } ); > > 60 } > > 61 > > 70 @Entity > > 71 @Table(name = "animal") > > 72 @IdClass(IdWithSubId.class) > > 73 public static class Animal { > > 74 > > 75 @Id > > 76 @GeneratedValue(strategy = GenerationType.IDENTITY) > > 77 private Long id; > > 78 > > 79 @Id > > 80 @Column(name = "sub_id") > > 81 private Long subId; > > 82 > > > > > > From: Jason Pyeron [mailto:jpye...@pdinc.us] > Sent: Tuesday, April 21, 2020 1:32 AM > To: 'hibernate-us...@lists.jboss.org' > Subject: HHH-6044 and partial identifier generation - No part of a composite > identifier > may be null HibernateException > > > > [note this is an issue with sequences too] > > > > Quoting > https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#i > dentifiers-composite-nonaggregated > > With non-aggregated composite identifiers, Hibernate also supports "partial" > generation of > the composite values. > > Example 135. @IdClass with partial identifier generation using @GeneratedValue > > > > I seem to be having the same issues as > https://hibernate.atlassian.net/browse/HHH-6044 > > > > I have existing tables / Entities (simplified): > > > > CREATE TABLE [cresaptown].[saar]( > >[id] [bigint] IDENTITY(1,1) NOT NULL primary key > > ); > > > > @Entity > > @Table(schema = "cresaptown", name = "saar") > > public class SystemAccessAuthorizationRequest > > { > > @Id > > @GeneratedValue > > Long id; > > } > > > > CREATE TABLE [cresaptown].[signature]( > >[rid] [bigint] IDENTITY(1,1) NOT NULL, > >[sid] [bigint] NOT NULL, > >PRIMARY KEY ([rid],[sid]), > >FOREIGN KEY([rid]) REFERENCES [cresaptown].[saar] ([id]) > > ); > > > > @Entity > > @Table(schema = "cresaptown", name = "signature") > > @IdClass(Signature.ID.class) > > public class Signature > > { > > @Id > > @Column(name = "sid") > > @GeneratedValue > > Long sid; > > > > @Id > > @JoinColumn(name = "rid") > > @ManyToOne > > SystemAccessAuthorizationRequest rid; >
Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier generation - No part of a composite identifier may be null HibernateException
I have been reviewing the change set, I see where Fabio was going. This looks like it will address the Identify vs Sequence issue. That will still leave the IncrediblySillyJpaMapsIdMappedIdentifierValueMarshaller not handling the generation like the NormalMappedIdentifierValueMarshaller does. Stack trace when using @Id Long id2: EmbeddedComponentType(ComponentType).instantiate(EntityMode) line: 587 AbstractEntityTuplizer$NormalMappedIdentifierValueMarshaller.getIdentifier(Object, EntityMode, SharedSessionContractImplementor) line: 322 PojoEntityTuplizer(AbstractEntityTuplizer).getIdentifier(Object, SharedSessionContractImplementor) line: 219 Stack trace when using @Id @ManyToOne SomeEntity id2: AbstractEntityTuplizer$IncrediblySillyJpaMapsIdMappedIdentifierValueMarshaller.getIdentifier(Object, EntityMode, SharedSessionContractImplementor) line: 365 AbstractEntityTuplizer$IncrediblySillyJpaMapsIdMappedIdentifierValueMarshaller.getIdentifier(Object, EntityMode, SharedSessionContractImplementor) line: 364 PojoEntityTuplizer(AbstractEntityTuplizer).getIdentifier(Object, SharedSessionContractImplementor) line: 219 -Jason From: andrea boriero Sent: Tuesday, April 21, 2020 12:20 PM To: Jason Pyeron Cc: Hibernate Dev Subject: Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier generation - No part of a composite identifier may be null HibernateException there is a PR related to this issue ( https://github.com/hibernate/hibernate-orm/pull/3105), you can try to verify if it solves the problem On Tue, 21 Apr 2020 at 16:15, Jason Pyeron mailto:jpye...@pdinc.us> > wrote: How can I help on HHH-9662 ? I have found that this fails with sequences too, when the composite identifier is another entity. This works: @Id @Column(name = "registration_number") @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long registrationNumber; @Id @Column(name = "publisher_id") private Integer publisherId; but, this does not: @Id @Column(name = "registration_number") @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long registrationNumber; @Id @JoinColumn(name = "publisher_id") @ManyToOne private Publisher publisherId; -Jason > -Original Message- > From: hibernate-dev-boun...@lists.jboss.org > <mailto:hibernate-dev-boun...@lists.jboss.org> > [mailto:hibernate-dev-boun...@lists.jboss.org > <mailto:hibernate-dev-boun...@lists.jboss.org> ] > On Behalf Of Jason Pyeron > Sent: Tuesday, April 21, 2020 9:23 AM > To: hibernate-us...@lists.jboss.org <mailto:hibernate-us...@lists.jboss.org> > ; hibernate-dev@lists.jboss.org <mailto:hibernate-dev@lists.jboss.org> > Subject: Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier > generation - No > part of a composite identifier may be null HibernateException > > Turns out this issue may be a duplicate of a known issue, taking this over to > the dev > list. > > > > org/hibernate/test/annotations/cid/CompositeIdIdentityTest.java: > > 7 package org.hibernate.test.annotations.cid; > > 48 @RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class) > > 49 @TestForIssue( jiraKey = "HHH-9662" ) > > 50 public class CompositeIdIdentityTest extends > BaseCoreFunctionalTestCase { > > 51 > > 52 @Test > > 53 @FailureExpected( jiraKey = "HHH-9662" ) > > 54 public void testCompositePkWithIdentity() throws Exception { > > 55 doInHibernate( this::sessionFactory, session -> { > > 56 Animal animal = new Animal(); > > 57 animal.setSubId( 123L ); > > 58 session.persist(animal); > > 59 } ); > > 60 } > > 61 > > 70 @Entity > > 71 @Table(name = "animal") > > 72 @IdClass(IdWithSubId.class) > > 73 public static class Animal { > > 74 > > 75 @Id > > 76 @GeneratedValue(strategy = GenerationType.IDENTITY) > > 77 private Long id; > > 78 > > 79 @Id > > 80 @Column(name = "sub_id") > > 81 private Long subId; > > 82 > > > > > > From: Jason Pyeron [mailto:jpye...@pdinc.us <mailto:jpye...@pdinc.us> ] > Sent: Tuesday, April 21, 2020 1:32 AM > To: 'hibernate-us...@lists.jboss.org <mailto:hibernate-us...@lists.jboss.org> > ' mailto:hiber
Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier generation - No part of a composite identifier may be null HibernateException
I spent the whole day tracking down / debugging / updating the org.hibernate.dialect.SQLServer2012Dialect and associated functions. I will continue tomorrow. On a side note SQL Server does not allow the identity column to be specified in the insert. As such the insert SQL statements generated by EntityIdentityInsertAction are bad, resulting in a com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert explicit value for identity column in table X when IDENTITY_INSERT is set to OFF. > -Original Message- > From: hibernate-dev-boun...@lists.jboss.org > On Behalf Of Jason > Pyeron > Sent: Tuesday, April 21, 2020 1:18 PM > To: 'Hibernate Dev' > Subject: Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier > generation - No part of a > composite identifier may be null HibernateException > > I have been reviewing the change set, I see where Fabio was going. This looks > like it will address the > Identify vs Sequence issue. That will still leave the > IncrediblySillyJpaMapsIdMappedIdentifierValueMarshaller not handling the > generation like the > NormalMappedIdentifierValueMarshaller does. > > > > Stack trace when using @Id Long id2: > > > > EmbeddedComponentType(ComponentType).instantiate(EntityMode) line: 587 > > AbstractEntityTuplizer$NormalMappedIdentifierValueMarshaller.getIdentifier(Object, > EntityMode, > SharedSessionContractImplementor) line: 322 > > PojoEntityTuplizer(AbstractEntityTuplizer).getIdentifier(Object, > SharedSessionContractImplementor) > line: 219 > > > > Stack trace when using @Id @ManyToOne SomeEntity id2: > > > > AbstractEntityTuplizer$IncrediblySillyJpaMapsIdMappedIdentifierValueMarshaller.getIdentifier(Object, > EntityMode, SharedSessionContractImplementor) line: 365 > > AbstractEntityTuplizer$IncrediblySillyJpaMapsIdMappedIdentifierValueMarshaller.getIdentifier(Object, > EntityMode, SharedSessionContractImplementor) line: 364 > > PojoEntityTuplizer(AbstractEntityTuplizer).getIdentifier(Object, > SharedSessionContractImplementor) > line: 219 > > > > -Jason > > > > > > From: andrea boriero > Sent: Tuesday, April 21, 2020 12:20 PM > To: Jason Pyeron > Cc: Hibernate Dev > Subject: Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier > generation - No part of a > composite identifier may be null HibernateException > > > > there is a PR related to this issue ( > https://github.com/hibernate/hibernate-orm/pull/3105), you can > try to verify if it solves the problem > > > > On Tue, 21 Apr 2020 at 16:15, Jason Pyeron <mailto:jpye...@pdinc.us> > wrote: > > How can I help on HHH-9662 ? > > I have found that this fails with sequences too, when the composite > identifier is another entity. > > This works: > @Id > @Column(name = "registration_number") > @GeneratedValue(strategy = GenerationType.SEQUENCE) > private Long registrationNumber; > > @Id > @Column(name = "publisher_id") > private Integer publisherId; > > but, this does not: > > @Id > @Column(name = "registration_number") > @GeneratedValue(strategy = GenerationType.SEQUENCE) > private Long registrationNumber; > > @Id > @JoinColumn(name = "publisher_id") > @ManyToOne > private Publisher publisherId; > > -Jason > > > > -Original Message- > > From: hibernate-dev-boun...@lists.jboss.org > > <mailto:hibernate-dev-boun...@lists.jboss.org> > [mailto:hibernate-dev-boun...@lists.jboss.org > <mailto:hibernate-dev-boun...@lists.jboss.org> ] > > On Behalf Of Jason Pyeron > > Sent: Tuesday, April 21, 2020 9:23 AM > > To: hibernate-us...@lists.jboss.org > > <mailto:hibernate-us...@lists.jboss.org> ; hibernate- > d...@lists.jboss.org <mailto:hibernate-dev@lists.jboss.org> > > Subject: Re: [hibernate-dev] HHH-6044 / HHH-9662 and partial identifier > > generation - No > > part of a composite identifier may be null HibernateException > > > > Turns out this issue may be a duplicate of a known issue, taking this over > > to the dev > > list. > > > > > > > > org/hibernate/test/annotations/cid/CompositeIdIdentityTest.java: > > > > 7 package org.hibernate.test.annotations.cid; > > > > 48 @RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class) > > > > 49 @TestForIssue( jiraKey = "HHH-9662" ) > > > > 50 public class CompositeIdIdentityTest extends > > BaseCoreFunctionalTestCase { > &g
[hibernate-dev] run a single unit test???? do I really have to manually put -x for every task I do not want?
Does anyone know how to get a single unit test to run without building a battleship too? Tried in eclipse too. ./gradlew test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest ... 5 minutes later ... FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':documentation:test'. > No tests found for given includes: > [org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest](--tests > filter) * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warnings BUILD FAILED in 4m 38s 36 actionable tasks: 35 executed, 1 up-to-date -- Jason Pyeron | Architect PD Inc| 10 w 24th St | Baltimore, MD | .mil: jason.j.pyeron@mail.mil .com: jpye...@pdinc.us tel : 202-741-9397 ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] run a single unit test speed up?
I got it down to BUILD SUCCESSFUL in 2m 32s 27 actionable tasks: 5 executed, 22 up-to-date By using ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest Package___ Tests DurationSuccess rate org.hibernate.test.annotations.cid 1 0.586s__100% For an approximate 250x slow down compared to the test execution, sigh. > -Original Message- > From: hibernate-dev-boun...@lists.jboss.org > On Behalf Of Jason > Pyeron > Sent: Wednesday, April 22, 2020 4:48 PM > To: 'Hibernate Dev' > Subject: [hibernate-dev] run a single unit test do I really have to > manually put -x for every task > I do not want? > > Does anyone know how to get a single unit test to run without building a > battleship too? Tried in > eclipse too. > > ./gradlew test --tests > org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest > > ... 5 minutes later ... > > FAILURE: Build failed with an exception. > > * What went wrong: > Execution failed for task ':documentation:test'. > > No tests found for given includes: > [org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest](--tests > filter) > > * Try: > Run with --stacktrace option to get the stack trace. Run with --info or > --debug option to get more log > output. Run with --scan to get full insights. > > * Get more help at https://help.gradle.org > > Deprecated Gradle features were used in this build, making it incompatible > with Gradle 5.0. > Use '--warning-mode all' to show the individual deprecation warnings. > See > https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warnings > > BUILD FAILED in 4m 38s > 36 actionable tasks: 35 executed, 1 up-to-date > > -- > Jason Pyeron | Architect > PD Inc| > 10 w 24th St | > Baltimore, MD | > > .mil: jason.j.pyeron@mail.mil > .com: jpye...@pdinc.us > tel : 202-741-9397 > > > > > ___ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
[hibernate-dev] HHH-10956 fixed, pull request pending
This fix addresses partially-generated composite id failure introduced with HHH-4848. The pull request is at https://github.com/hibernate/hibernate-orm/pull/3368 . Please review and can this be backported to 5.2? We have cherry picked it and applied it to 5.2.18.Final on JDK8 with SQLServer2012Dialect and are tracking its performance (our bug 2092). HHH-9662 will continue to need some work for SQL Server, but otherwise seems to work nicely. I have opened HHH-13970 as a sub-task for it so it can be treated as a known issue. The unit tests for this issue have some issues in the hibernate provided unit testing framework and I have opened a ticket (HHH-13971) for those issues. It is likely a very low priority item. v/r, Jason Pyeron $ git logg -5 * 4138772878 2020-04-22 (HEAD -> HHH-10956) HHH-10956 put one line if in {} jpye...@pdinc.us * 683e00a399 2020-04-22 HHH-10956 added more complext tests with self referential FK jpye...@pdinc.us * 9653fee5b7 2020-04-22 HHH-10956 fixed failed insertion with IdClass with partial identifier generation jpye...@pdinc.us * eca5c5a884 2020-04-22 HHH-10956 created test cases IdClass with partial identifier generatiod, all marked @FailureExpected jpye...@pdinc.us * 5104c4b7f3 2020-03-26 (tag: 5.4.13) 5.4.13 gbad...@redhat.com diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java index 880831..d9f8b65ec9 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java @@ -264,6 +264,17 @@ public class SimpleValue implements KeyValue { private IdentifierGenerator identifierGenerator; + /** + * Returns the cached identifierGenerator. + * + * @return IdentifierGenerator null if + * {@link #createIdentifierGenerator(IdentifierGeneratorFactory, Dialect, String, String, RootClass)} was never + * completed. + */ + public IdentifierGenerator getIdentifierGenerator() { + return identifierGenerator; + } + @Override public IdentifierGenerator createIdentifierGenerator( IdentifierGeneratorFactory identifierGeneratorFactory, diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java index 3d137219d0..53fa2d9d12 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java @@ -26,8 +26,10 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.id.Assigned; import org.hibernate.loader.PropertyPath; import org.hibernate.mapping.Component; +import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; +import org.hibernate.mapping.SimpleValue; import org.hibernate.metamodel.spi.MetamodelImplementor; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.property.access.spi.Getter; @@ -168,11 +170,13 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { } else { identifierMapperType = (CompositeType) mapper.getType(); + KeyValue identifier = mappingInfo.getIdentifier(); mappedIdentifierValueMarshaller = buildMappedIdentifierValueMarshaller( getEntityName(), getFactory(), (ComponentType) entityMetamodel.getIdentifierProperty().getType(), - (ComponentType) identifierMapperType + (ComponentType) identifierMapperType, + identifier ); } } @@ -274,7 +278,8 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { String entityName, SessionFactoryImplementor sessionFact
Re: [hibernate-dev] run a single unit test speed up?
> -Original Message- > From: Sanne Grinovero > Sent: Thursday, April 23, 2020 8:04 AM > > Hi Jason, > > I'm surprised. It's not instantaneous here either, but it doesn't take > minutes - provided you've built the project before and didn't change a > lot of code. Just the one unit test. > > If I run such a test for the first time, possibly after having > switched branches, I'll get test results in ~20 seconds; most of this What versions of tools in your tool chain are you using? > is spent recompiling. But if I repeat the same command right away, it > will complete in ~1 second. > > What do you see if you repeat the test a second time after having just run it? After multiple builds it stabilized at 90 seconds. > > Just for reference, a full build runnig all tests on H2 takes 6 > minutes on my machine. > > Thanks, > Sanne > > > > On Wed, 22 Apr 2020 at 21:59, Jason Pyeron wrote: > > > > I got it down to BUILD SUCCESSFUL in 2m 32s > > 27 actionable tasks: 5 executed, 22 up-to-date > > > > By using > > > > ./gradlew :hibernate-core:test --tests > org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest > > > > > > Package___ Tests DurationSuccess rate > > org.hibernate.test.annotations.cid 1 0.586s__100% > > > > For an approximate 250x slow down compared to the test execution, sigh. > > > > > -Original Message- > > > From: hibernate-dev-boun...@lists.jboss.org > > > On > Behalf Of Jason > > > Pyeron > > > Sent: Wednesday, April 22, 2020 4:48 PM > > > To: 'Hibernate Dev' > > > Subject: [hibernate-dev] run a single unit test do I really have to > > > manually put - > x for every task > > > I do not want? > > > > > > Does anyone know how to get a single unit test to run without building a > > > battleship > too? Tried in > > > eclipse too. > > > > > > ./gradlew test --tests > org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest > > > > > > ... 5 minutes later ... > > > > > > FAILURE: Build failed with an exception. > > > > > > * What went wrong: > > > Execution failed for task ':documentation:test'. > > > > No tests found for given includes: > > > [org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest](--tests > filter) > > > > > > * Try: > > > Run with --stacktrace option to get the stack trace. Run with --info or > > > --debug option > to get more log > > > output. Run with --scan to get full insights. > > > > > > * Get more help at https://help.gradle.org > > > > > > Deprecated Gradle features were used in this build, making it > > > incompatible with Gradle > 5.0. > > > Use '--warning-mode all' to show the individual deprecation warnings. > > > See > https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warn > ings > > > > > > BUILD FAILED in 4m 38s > > > 36 actionable tasks: 35 executed, 1 up-to-date > > > > > > -- > > > Jason Pyeron | Architect > > > PD Inc| > > > 10 w 24th St | > > > Baltimore, MD | > > > > > > .mil: jason.j.pyeron@mail.mil > > > .com: jpye...@pdinc.us > > > tel : 202-741-9397 > > > > > > > > > > > > > > > ___ > > > hibernate-dev mailing list > > > hibernate-dev@lists.jboss.org > > > https://lists.jboss.org/mailman/listinfo/hibernate-dev > > > > ___ > > hibernate-dev mailing list > > hibernate-dev@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/hibernate-dev > > ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] [hibernate/hibernate-orm] HHH-10956 test cases and fix (#3368)
Github has been down for a while, so moving to mailing list. > Hi @pdinc-oss , > > the issue it is how you define the `IdClass` > > for such a case > > ``` > @Entity > @IdClass(PK.class) > public static class NodeS { > > @Id > @GeneratedValue(strategy = GenerationType.SEQUENCE) > private Long nid; > > @Id > @ManyToOne > private HeadS hid; > ... > } > ``` > > the class has to be > > ``` > class PK implements Serializable { > > private Long nid; > > private HeadS hid; > > public PK(Long nid, HeadS hid) { > this.nid = nid; > this.hid = hid; > } > ... > } > ``` JPA 2 spec 2.4.1.3 Examples of Derived Identities, Case (a): The dependent entity uses IdClass to represent a composite key: ``` public class DependentId { String name; // matches name of @Id attribute long emp; // matches name of @Id attribute and type of Employee PK } @Entity @IdClass(DependentId.class) public class Dependent { @Id String name; // id attribute mapped by join column default @Id @ManyToOne Employee emp; ... } ``` HeadS is the Entity type and its Id type is Long. I backed out the changes to SimpleValue.java/AbstractEntityTuplizer.java and changed the IdClasses to match and it does pass the tests in Hibernate. But when testing 2.4.1.3, case a without the patch the following tests fails: - testCompositePkWithIdentityAndFKByAuto: No part of a composite identifier may be null - testCompositePkWithIdentityAndFKByAuto2: No part of a composite identifier may be null - testCompositePkWithIdentityAndFKBySequence: No part of a composite identifier may be null - testCompositePkWithIdentityAndFKBySequence2: No part of a composite identifier may be null - testCompositePkWithIdentityAndFKByTable: No part of a composite identifier may be null - testCompositePkWithIdentityAndFKByTable2: No part of a composite identifier may be null These tests are expected to fail / ignored: - testCompositePkWithIdentityAndFKByIdentity: No part of a composite identifier may be null - testCompositePkWithIdentityAndFKByIdentity2: skipped -Jason — You are receiving this because you were mentioned. Reply to this email directly, https://github.com/hibernate/hibernate-orm/pull/3368#issuecomment-618352419, or https://github.com/notifications/unsubscribe-auth/AAQUDIQWBZ5E4INWC5ELIZ3ROASJXANCNFSM4MOS2VNA. ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
[hibernate-dev] Trying to understand the significance and use of the sequence methods in Dialect
Other than the javadocs, are these documented anywhere? * public String getSequenceNextValString(String sequenceName) * public String getSelectSequenceNextValString(String sequenceName) I have been following their usage throughout the codebase, but it is not easy. Is getSequenceNextValString only used in place of single values? E.g. INSERT INTO NEW_USER VALUES (SEQ_USER.NEXTVAL, 'Adams', 'John') ? Or are there other uses? Is getSelectSequenceNextValString only used to get the "batch" for Hibernate's future issuance of ids? The reason I am asking is we would like to leverage the MS SQL Server's sp_sequence_get_range . By using the approach of using the stored procedure for Hibernate's allocation and otherwise using an increment by 1 allows higher efficiency with the Hibernate based application and prevent breaking legacy access to the table/use of the sequence. This topic was unclearly broached in HHH-10130. Internet research below... Take the following example: CREATE SEQUENCE [dbo].[hibernate_sequence2] AS [bigint] START WITH 1 INCREMENT BY 1 CACHE 200 ; CREATE TABLE [MyTable2] ( [ID] [bigint] PRIMARY KEY NOT NULL DEFAULT (NEXT VALUE FOR [dbo].[hibernate_sequence2]), [Title] [nvarchar](64) NOT NULL ); insert into MyTable2 (Title) values ('test 1'); insert into MyTable2 (Title) values ('test 2'); insert into MyTable2 (Title) values ('test 3'); insert into MyTable2 (Title) values ('test 4'); select * from MyTable2; --IDTitle --1 test 1 --2 test 2 --3 test 3 --4 test 4 DECLARE @range_first_value_output sql_variant ; declare @range_size int=50+1; DECLARE @sequence_increment sql_variant ; declare @range_last_value sql_variant; EXEC sys.sp_sequence_get_range @sequence_name = N'[dbo].[hibernate_sequence2]' , @range_size = @range_size , @range_first_value = @range_first_value_output OUTPUT , @sequence_increment = @sequence_increment OUTPUT , @range_last_value = @range_last_value OUTPUT ; SELECT @range_first_value_output AS FirstNumber, @sequence_increment as sequence_increment, @range_last_value as range_last_value ; --FirstNumber sequence_increment range_last_value -- 51 55 insert into MyTable2 (Title) values ('test 5'); select * from MyTable2; --IDTitle --1 test 1 --2 test 2 --3 test 3 --4 test 4 --56test 5 I know there are issues of "knowing" the @SequenceGenerator(allocationSize), but I will assume a fixed 50 for now. Internet research and other useless links... 1: Not hibernate, but same goal - https://groups.google.com/forum/#!topic/ebean/wG6VyVfEMQk 2: Not helpful - https://stackoverflow.com/questions/17780394/hibernate-identity-vs-sequence-entity-identifier-generators 3: Closest Hibernate Hit - https://hibernate.atlassian.net/browse/HHH-10130 4: My google searches - https://www.google.com/search?safe=off&q=%22sp_sequence_get_range%22+hibernate and https://www.google.com/search?safe=off&q=%22sp_sequence_get_range%22+jpa 5: An interesting discussion, but not applicable - https://hibernate.atlassian.net/browse/HHH-10560 6: Sequences Added to SQL Server Dialect - https://hibernate.atlassian.net/browse/HHH-8440 7: My JIRA search - https://hibernate.atlassian.net/browse/HHH-6950?jql=(text%20~%20sequence%20or%20text%20~%20sp_sequence_get_range%20)%20and%20(text%20~%20SQLServer%20or%20text%20~%20%22SQL%20Server%22%20or%20text%20~%20SQLServer2012Dialect%20or%20text%20~%20SQLServer2008Dialect%20or%20text%20~%20SQLServer2005Dialect%20or%20text%20~%20SQLServerDialect) -Jason -- Jason Pyeron | Architect PD Inc| 10 w 24th St | Baltimore, MD | .mil: jason.j.pyeron@mail.mil .com: jpye...@pdinc.us tel : 202-741-9397 ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] run a single unit test speed up?
> -Original Message- > From: Sanne Grinovero > Sent: Thursday, April 23, 2020 8:43 AM > > On Thu, 23 Apr 2020 at 13:20, Jason Pyeron wrote: > > > > > -Original Message- > > > From: Sanne Grinovero > > > Sent: Thursday, April 23, 2020 8:04 AM > > > > > > Hi Jason, > > > > > > I'm surprised. It's not instantaneous here either, but it doesn't take > > > minutes - provided you've built the project before and didn't change a > > > lot of code. > > > > Just the one unit test. > > > > > > > > If I run such a test for the first time, possibly after having > > > switched branches, I'll get test results in ~20 seconds; most of this > > > > What versions of tools in your tool chain are you using? > > # Gradle > Using the gradle wrapper, so the same as what we have in each branch > of Hibernate ORM. > I don't think Gradle's version matters, we just recently used version > 4, then 5, now 6 and they all perform well. > > # JDK > Shouldn't matter either as I have many versions installed, and from > different vendors, to run various tests. Never noticed one being > particularly slow. > > # OS > I run Fedora Linux exclusively, as most members of the team. Some of > us are on OSX, some use different Linux distributions. Hmmm, switched to Centos 7 from Windows 10 BUILD SUCCESSFUL in 48s 27 actionable tasks: 3 executed, 24 up-to-date [root@localhost hibernate-orm]# nano hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java [root@localhost hibernate-orm]# git diff diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java index 3ec3ffc..0936dcb 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java @@ -51,7 +51,7 @@ public class CompositeIdFkGeneratedValueIdentityTest extends BaseCoreFunctionalT HeadS head = new HeadS(); head.name = "Head by Sequence"; session.persist( head ); - System.out.println( "VALUE =>" + head.name + "=" + head.hid ); + System.out.println( "CHANGED VALUE =>" + head.name + "=" + head.hid ); NodeS node = new NodeS(); node.hid = head; [root@localhost hibernate-orm]# ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest [WARN] Skipping Java module path integration tests because the JDK does not support it > Task :hibernate-core:compileTestJava Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warnings BUILD SUCCESSFUL in 46s 27 actionable tasks: 3 executed, 24 up-to-date [root@localhost hibernate-orm]# > > > > is spent recompiling. But if I repeat the same command right away, it > > > will complete in ~1 second. [root@localhost hibernate-orm]# ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest; ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest; ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest; ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest ... BUILD SUCCESSFUL in 6m 46s 27 actionable tasks: 27 executed ... BUILD SUCCESSFUL in 13s 27 actionable tasks: 1 executed, 26 up-to-date ... BUILD SUCCESSFUL in 11s 27 actionable tasks: 1 executed, 26 up-to-date ... BUILD SUCCESSFUL in 10s 27 actionable tasks: 1 executed, 26 up-to-date > > > > > > What do you see if you repeat the test a second time after having just > > > run it? > > > > After multiple builds it stabilized at 90 seconds. > > Very odd. Having some old style spinning drives? AFAIK we all use fast > solid state drives for devel
Re: [hibernate-dev] Subject : Starting 5.4.16 release
Is there a reason to not include HHH-13959? > -Original Message- > From: hibernate-dev-boun...@lists.jboss.org > [mailto:hibernate-dev-boun...@lists.jboss.org] > On Behalf Of andrea boriero > Sent: Monday, May 18, 2020 10:23 AM > To: Hibernate Dev > Subject: [hibernate-dev] Subject : Starting 5.4.16 release > > Please do not push anything to 5.4 branch. > > Thanks, > Andrea > ___ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
[hibernate-dev] HHH-6221 foreign keys with shared columns
I have been hunting around this morning trying to mitigate some issues of our schema and JPA mapping and https://hibernate.atlassian.net/browse/HHH-6221 seems most related. This is a specific case following on §2.4.1 and the other bugs I have worked with recently. Is there any more history on this bug than is in the comments of it and the related tickets? We are going to have to dive in and fix and was hoping to have a good survey of the landscape first. We will make test case(s) along with some patches. --- BREAK --- Tracking internally as https://projects.pdinc.us/show_bug.cgi?id=2115 . In our codebase we got here because of (edited for clarity) @ManyToOne @JoinColumns ({ @JoinColumn(name = "id", referencedColumnName = "request_id", insertable = false, updatable = false), @JoinColumn(name = "head", referencedColumnName = "id") }) Signature head; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) Long id; Repeated column in mapping for entity: Entity column: column (should be mapped with insert="false" update="false") Which then leads to Mixing insertable and non insertable columns in a property is not allowed: Entity.column at org.hibernate.cfg.Ejb3Column.checkPropertyConsistency(Ejb3Column.java:718) At this moment, using the following workaround: @ManyToOne @JoinColumns ({ @JoinColumn(name = "id", referencedColumnName = "request_id", insertable = false, updatable = false), @JoinColumn(name = "head", referencedColumnName = "id", insertable = false, updatable = false) }) Signature head; public void setHead(Signature head) { this.head = head; // https://stackoverflow.com/a/49019669/58794 head2115 = head == null ? null : head.getId(); } private Long head2115; @Column(name = "head") private Long getHead2115() { return head2115; } Note: JoinFormula workaround is doubly not acceptable – 1. Nonstandard, 2. org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
[hibernate-dev] Re: HHH-6221 foreign keys with shared columns
Has there been any thoughts on this issue? The mitigation(below email) does not work for a more fringe case discovered today: Class A { @Id @ManyToOne B src @Id @ManyToOne B target String data } Class B { @Id @ManyToOne C c @Id Long id } create table A ( b_id_c_1 bigint not null, b_id_c_2 bigint not null, b_id_src bigint not null, b_id_target bigint not null, data varchar(max) null, primary key (b_id_c_1, b_id_c_2,b_id_src,b_id_target), foreign key (b_id_c_1, b_id_c_2,b_id_src) references B(b_id_c_1, b_id_c_2, b_id), foreign key (b_id_c_1, b_id_c_2,b_id_target) references B(b_id_c_1, b_id_c_2, b_id) ); Also worth mentioning that the mitigation below requires manual re-setting of the ManyToOne properties after the referenced object is persisted. From: Jason Pyeron [mailto:jpye...@pdinc.us] Sent: Sunday, May 24, 2020 1:09 PM To: INTERNAL Subject: RE: HHH-6221 foreign keys with shared columns @ManyToOne @JoinColumns ({ @JoinColumn(name = "request_id", referencedColumnName = "request_id", insertable = false, updatable = false), @JoinColumn(name = "parent", referencedColumnName = "id"/*, insertable = false, updatable = false*/) }) public Signature getParent() { return this.parent; } And public static void checkPropertyConsistency(Ejb3Column[] columns, String propertyName) { int nbrOfColumns = columns.length; if ( nbrOfColumns > 1 ) { for (int currentIndex = 1; currentIndex < nbrOfColumns; currentIndex++) { if (columns[currentIndex].isFormula() || columns[currentIndex - 1].isFormula()) { continue; } /*if ( columns[currentIndex].isInsertable() != columns[currentIndex - 1].isInsertable() ) { throw new AnnotationException( "Mixing insertable and non insertable columns in a property is not allowed: " + propertyName ); }*/ if ( columns[currentIndex].isNullable() != columns[currentIndex - 1].isNullable() ) { throw new AnnotationException( "Mixing nullable and non nullable columns in a property is not allowed: " + propertyName ); } /*if ( columns[currentIndex].isUpdatable() != columns[currentIndex - 1].isUpdatable() ) { throw new AnnotationException( "Mixing updatable and non updatable columns in a property is not allowed: " + propertyName ); }*/ if ( !columns[currentIndex].getTable().equals( columns[currentIndex - 1].getTable() ) ) { throw new AnnotationException( "Mixing different tables in a property is not allowed: " + propertyName ); } } } } Does not work… Hibernate: insert into REDACTED (a, b, c, d, e, f, g, h, i, j, id, request_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) Where as @ManyToOne @JoinColumns ({ @JoinColumn(name = "request_id", referencedColumnName = "request_id", insertable = false, updatable = false), @JoinColumn(name = "parent", referencedColumnName = "id", insertable = false, updatable = false) }) public Signature getParent() { return this.parent; } public void setParent(final Signature parent) { this.parent = parent; setParent2115(parent == null ? null : parent.getId()); } Hibernate: insert into REDACTED (a, b, c, d, parent, e, f, g, h, i, j, id, request_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) Works. From: Jason Pyeron [mailto:jpye...@pdinc.us] Sent: Friday, May 22, 2020 12:49 PM To: 'Hibernate Dev' Subject: HHH-6221 foreign keys with shared columns I have been hunting around this morning trying to mitigate some issues of our schema and JPA mapping and https://hibernate.atlassian.net/browse/HHH-6221 seems most related. This is a specific case following on §2.4.1 and the other bugs I have worked with recently. Is there any more history on this bug than is in the comments of it and the related tickets? We are going to have to dive in and fix and was hoping to have a good survey of the landscape first. We wil