[Hibernate-JIRA] Created: (HHH-2326) NullPointerException from merge on composite id
by Greg Adams (JIRA)
NullPointerException from merge on composite id
-----------------------------------------------
Key: HHH-2326
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2326
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1
Environment: Hibernate 3.2.1ga, tested against Oracle 10g and Derby
Reporter: Greg Adams
Priority: Critical
Attachments: HibernateMergeBug.zip
Merge is throwing an NPE from the bowels of Hibernate when I have a class mapped with a composite ID.
Stacktrace:
[junit] java.lang.NullPointerException
[junit] at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:112)
[junit] at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:120)
[junit] at org.hibernate.type.EntityType.getHashCode(EntityType.java:279)
[junit] at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:189)
[junit] at org.hibernate.engine.EntityKey.generateHashCode(EntityKey.java:104)
[junit] at org.hibernate.engine.EntityKey.<init>(EntityKey.java:48)
[junit] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:100)
[junit] at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:687)
[junit] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:669)
[junit] at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:245)
[junit] at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
[junit] at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
[junit] at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
[junit] at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
[junit] at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
[junit] at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
[junit] at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
[junit] at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
[junit] at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:437)
[junit] at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:194)
[junit] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:123)
[junit] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
[junit] at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
[junit] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
[junit] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
[junit] at com.foo.test.HibernateTest.doMerge(Unknown Source)
[junit] at com.foo.test.HibernateTest.testInsert(Unknown Source)
[junit] at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
[junit] at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
[junit] at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
[junit] at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
[junit] at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
[junit] at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
[junit] at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
[junit] at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
[junit] at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
[junit] at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
[junit] at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
I've attached a zipped-up project that reproduces the error. Just extract and run ant.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
15 years, 3 months
[Hibernate-JIRA] Created: (ANN-626) @Generated annotation not inserting during insert
by Rob (JIRA)
@Generated annotation not inserting during insert
-------------------------------------------------
Key: ANN-626
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-626
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga, 3.2.0.ga
Environment: MSSQL 9.00.3042.00
Hibernate annotations version 3.2.0 GA and also tested 3.30 GA
Reporter: Rob
Priority: Critical
The @Generated annotation is not working similiar to the hbm generated tag.
Annotation Mapping:
@Generated(GenerationTime.INSERT)
@Column (name="CreatedOn", length=23, nullable=false, insertable=false, updatable=false)
private Date mCreatedOn;
Mapping Document:
<property name="createdOn" generated="insert" type="TimestampType">
<column name="CreatedOn" length="23"/>
</property>
The generated SQL (show_sql=true):
Hibernate: insert into Zone (CreatedByUserID, ZoneDescription, ZoneFile, ModifiedByUserID, ModifiedOn, ZoneName, RowStatus, SOAExpire, SOAMinimum, SOARefresh, SOARetry, SOAWho, ZoneTTL, ZoneType, ZoneClass) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt:
18:37:42 WARN org.hibernate.util.JDBCExceptionReporter 77 SQL Error: 515, SQLState: 23000
18:37:42 ERROR org.hibernate.util.JDBCExceptionReporter 78 Cannot insert the value NULL into column 'CreatedOn', table 'DB.dbo.Zone'; column does not allow nulls. INSERT fails.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 3 months
[Hibernate-JIRA] Created: (HHH-3917) @NotFound(action=NotFoundAction.IGNORE) results in EAGER loading for @ManyToOne(fetch = FetchType.LAZY) field
by Vlasov Igor (JIRA)
@NotFound(action=NotFoundAction.IGNORE) results in EAGER loading for @ManyToOne(fetch = FetchType.LAZY) field
-------------------------------------------------------------------------------------------------------------
Key: HHH-3917
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3917
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Reporter: Vlasov Igor
Hello
I try to use @org.hibernate.annotations.NotFound(action=NotFoundAction.IGNORE) annotation to avoid of throwing an exception IN
@JoinColumn(name = "UR_ID", referencedColumnName = "UR_ID")
@ManyToOne(fetch = FetchType.LAZY)
@org.hibernate.annotations.NotFound(action=NotFoundAction.IGNORE)
@Basic(optional=true)
private UserRole role;
Then it results me to EAGER loading of this field.
Throw days of debuging i have found that:
1. @org.hibernate.annotations.NotFound results in:
isNullable()=true
for org.hibernate.type.ManyToOneType
2. in org.hibernate.impl.SessionImpl and method internalLoad i can see:
LoadEventListener.LoadType type = nullable ?
LoadEventListener.INTERNAL_LOAD_NULLABLE :
eager ? LoadEventListener.INTERNAL_LOAD_EAGER : LoadEventListener.INTERNAL_LOAD_LAZY;
Threrefore we have LoadEventListener.INTERNAL_LOAD_NULLABLE type of loading my relation. !!!
and in class org.hibernate.event.LoadEventListener.INTERNAL_LOAD_NULLABLE I can see setAllowProxyCreation(false) !!!!
3. in org.hibernate.event.def.DefaultLoadEventListener in line 218 there is a condition:
if ( options.isAllowProxyCreation() ) {
return createProxyIfNecessary( event, persister, keyToLoad, options, persistenceContext );
} else {
return load(event, persister, keyToLoad, options);
}
In my case LoadEventListener.INTERNAL_LOAD_NULLABLE.isAllowProxyCreation() ==false !!
and it results in LOADING of Object !!!
Can we set LoadEventListener.INTERNAL_LOAD_NULLABLE.isAllowProxyCreation() to true ?
org.hibernate.event.LoadEventListener.INTERNAL_LOAD_NULLABLE = new LoadType("INTERNAL_LOAD_NULLABLE")
.setAllowNulls(true)
.setAllowProxyCreation(false)
.setCheckDeleted(false)
.setNakedEntityReturned(false);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 3 months
[Hibernate-JIRA] Created: (ANN-802) @Formula annotation does not set value into bean property
by Lincoln Baxter, III (JIRA)
@Formula annotation does not set value into bean property
---------------------------------------------------------
Key: ANN-802
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-802
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.4.0.GA
Environment: HSQLDB
14:46:43,879 INFO Version:15 - Hibernate Annotations 3.4.0.GA
14:46:43,908 INFO Environment:543 - Hibernate 3.3.0.SP1
14:46:43,926 INFO Environment:576 - hibernate.properties not found
14:46:43,934 INFO Environment:709 - Bytecode provider name : javassist
14:46:43,941 INFO Environment:627 - using JDK 1.4 java.sql.Timestamp handling
14:46:44,040 INFO Version:14 - Hibernate Commons Annotations 3.1.0.GA
Reporter: Lincoln Baxter, III
The @Formula annotation never assigns the value of the query into the bean field. As you can see, it is being selected, but the field never receives the value. Everything else works fine.
@Formula("id + 4")
private int numWatchers;
A snippit of the generated SQL
select story0_.id as id9_1_, ....... story0_.id + 4 as formula0_1_, ...... where story0_.id=?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 3 months
[Hibernate-JIRA] Created: (HBX-970) POJO generation should have full contructor as an option
by Alberto A. Flores (JIRA)
POJO generation should have full contructor as an option
--------------------------------------------------------
Key: HBX-970
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-970
Project: Hibernate Tools
Issue Type: Bug
Components: hbm2java, reverse-engineer
Affects Versions: 3.2beta9
Environment: Hibernate3, Oracle 10g
Reporter: Alberto A. Flores
When using hbm2java (for reverse engineering the database to generate POJOs), there is no real way to declare full constructor generation as an option (which is not required in Hibernate anyway). In a large table, I found the error of "can't create a constructor with more than 255 parameters" (which could easily grow if you use inheritance). We had to fix the PojoContructors.ftl code to never generate that full contructor.
Potential fixes:
- Find a way to initialize the BasicPojoClass to initialize the needFullContructor using <property> in the hbm2java
- Using the <property> feature within hbm2java, fix the PojoConstructor.ftl to check for a variable that is (optionally) visible by virtue of the <property> tag instead of always checking for "pojo.needFullConstructor"
- Provide a way to replace BasicPojoClass as part of the hbm2java task. By default, this uses the hardcoded code to always use this template.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 3 months