[Hibernate-JIRA] Created: (ANN-593) Ability for an @NamedQuery on a @MappedSuperclass to be copied up to the subclass
by John Newman (JIRA)
Ability for an @NamedQuery on a @MappedSuperclass to be copied up to the subclass
---------------------------------------------------------------------------------
Key: ANN-593
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-593
Project: Hibernate Annotations
Issue Type: Improvement
Components: binder
Affects Versions: 3.2.1
Environment: INFO Version:15 - Hibernate Annotations 3.2.1.GA
09:15:01,755 INFO Environment:500 - Hibernate 3.2.1
INFO SettingsFactory:81 - RDBMS: Microsoft SQL Server, version: 08.00.0760
09:15:06,114 INFO SettingsFactory:82 - JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2
09:15:06,255 INFO Dialect:151 - Using dialect: org.hibernate.dialect.SQLServerDialect
Reporter: John Newman
If I use a @MappedSuperclass (which is a very useful annotation btw) I have to manually copy any queries I want with taht class up to all subclasses. The binder should check any mapped superclasses and pull those named queries up. i.e.
/**
* Base User class that different projects user classes derive from.
* Hibernate annotations doesn't pick up that query, so you have to copy it up to your subclass
*/
@MappedSuperclass
@NamedQueries({
@NamedQuery(name="User.findByLoginName",
query="FROM User WHERE loginName = ?") // this is useless down here, i just put it here for reference
})
public class BaseUser<PK extends Serializable> extends IdEntity<PK> {
private static final long serialVersionUID = -4443522925041212381L;
protected String loginName;
@Column(unique=true)
public String getLoginName() {
return this.loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
}
/**
* Custom user class for a certain application
*/
@Entity
@Table(name="tbl_user")
@GenericGenerator(name=IdGen.NAME, strategy=IdGen.AUTO)
@NamedQueries({
@NamedQuery(name="User.findByLoginName",
query="FROM User WHERE loginName = ?") // had to copy this up from the base class
})
public class User extends BaseUser<Short> {
private static final long serialVersionUID = -6199544722824321999L;
private String firstName;
...
}
so in short it would be nice if the scanner would check for that and bind any named queries up to the subclass
--
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, 2 months
[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: (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