[Hibernate-JIRA] Created: (HHH-2536) NPE with custom SQL query and formula property
by Jörg Heinicke (JIRA)
NPE with custom SQL query and formula property
----------------------------------------------
Key: HHH-2536
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2536
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.1
Reporter: Jörg Heinicke
Priority: Minor
I have an object Balance which I map like the following (stripped):
<class name="Balance" entity-name="Balance" table="BALANCE">
...
<property name="reportDate" column="report_date" type="..." not-null="true"/>
<property name="year" formula="year(report_date)" type="..."/>
</class>
Now I have another object which is actually a cumulated view of the BALANCE table. For retrieving the values I use a custom SQL query. The mapping is almost the same (it is at least for the properties in question, but e.g. the ID mapping is different as it is a cumulated view).
<class name="PaymentStatisticsData">
...
<property name="reportDate" column="report_date" type="..." not-null="true"/>
<property name="year" formula="year(report_date)" type="..."/>
<loader query-ref="paymentStatisticsData"/>
</class>
<sql-query name="paymentStatisticsData" read-only="true">
<return class="PaymentStatisticsData"/>
select ...
</sql-query>
In theory there should be no difference, but the latter fails with the following NPE:
Caused by: java.lang.NullPointerException
at org.hibernate.loader.DefaultEntityAliases.intern(DefaultEntityAliases.java:133)
at org.hibernate.loader.DefaultEntityAliases.getSuffixedPropertyAliases(DefaultEntityAliases.java:106)
at org.hibernate.loader.DefaultEntityAliases.<init>(DefaultEntityAliases.java:52)
at org.hibernate.loader.ColumnEntityAliases.<init>(ColumnEntityAliases.java:16)
at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.generateCustomReturns(SQLQueryReturnProcessor.java:174)
at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:129)
at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:43)
at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:114)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:444)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:351)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
Hope that's all information you need.
Joerg
--
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
16 years, 10 months
[Hibernate-JIRA] Created: (HHH-2627) Generated properties leak prepared statements in Hibernate 3.2.3 and higher.
by Michael Werle (JIRA)
Generated properties leak prepared statements in Hibernate 3.2.3 and higher.
----------------------------------------------------------------------------
Key: HHH-2627
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2627
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1, 3.2.4, 3.2.3
Environment: Hibernate 3.2.2-4sp1, Oracle 10g (Oracle9Dialect)
Reporter: Michael Werle
Attachments: generated-lazy-statement-leak.patch
The fix for HHH-2393, in combination with a change to AbstractBatcher 11333 to the Hibernate 3.2 branch (comment is "sybase testsuite"), created a PreparedStatement leak for generated properties.
The reason is that, in revision 11333, org.hibernate.jdbc.AbstractBatcher#closeQueryStatement() was changed to check for the existence of the prepared statement in the statementsToClose collection instead of closing it unconditionally. The fix for HHH-2393 (revision 11117 in the Hibernate 3.2 branch) modified org.hibernate.persister.entity.AbstractEntityPersister#processGeneratedProperties() to make it use org.hibernate.jdbc.AbstractBatcher#closeQueryStatement() instead of org.hibernate.jdbc.AbstractBatcher#closeStatement(), which closes the statement without checking the statementsToClose collection. This is a problem because the statement in AbstractEntityPersister#processGeneratedProperties() is created with AbstractBatcher#prepareSelectStatement(), which does not add the statement to the statementsToClose collection.
The attached patch to org.hibernate.persister.entity.AbstractEntityPersister changes processGeneratedProperties() back to using AbstractBatcher#closeStatement() and obtains the result set through ResultSet#executeQuery() instead of using the batcher. This fixes the prepared statement leak and matches other usages of AbstractBatcher#prepareSelectStatement(), which also avoid using the batcher for their result sets. It also makes the same change in AbstractEntityPersister#initializeLazyPropertiesFromDatastore() becuase it has exactly the same problem.
No existing test cases are broken by the attached patch. I investigated ways to write a test case to explicitly verify that the result sets and statements were all being closed. However, because the counts in AbstractBatcher are private, and I do not know of a generic way to obtain counts through the JDBC API, I could not figure out a good way to do so without using reflection to access the private fields, which none of the existing test cases seem to do.
The bug was discovered when running my web app against Oracle, which runs out of cursors when connections are leaked -- not exactly a practical way to write a test case, but sufficient to prove that the bug exists and is fixed by the patch.
--
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
16 years, 10 months
[Hibernate-JIRA] Created: (EJB-286) Hibernate does not honor @Column(name=...) annotation with IdClass
by Dusty (JIRA)
Hibernate does not honor @Column(name=...) annotation with IdClass
------------------------------------------------------------------
Key: EJB-286
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-286
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.3.1.GA
Environment: Netbeans 5.5, Java6
Reporter: Dusty
I'have an Entity which uses an IdClass, when I execute the simplest query Hibernate fails because it's using the name of the attribute instead of the one indicated by the @Column annotation.
The IdClass is defined as follows:
public class DomainAdminId implements Serializable {
private String domainName;
private String adminUser;
public DomainAdminId() {
}
public DomainAdminId(String domainName, String adminUser) {
this.domainName = domainName;
this.adminUser = adminUser;
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public String getAdminUser() {
return adminUser;
}
public void setAdminUser(String adminUser) {
this.adminUser = adminUser;
}
public boolean equals(Object o) {
return ((o instanceof DomainAdminId) &&
domainName.equals(((DomainAdminId)o).getDomainName()) &&
adminUser.equals(((DomainAdminId)o).getAdminUser()));
}
public int hashCode() {
return (domainName+adminUser).hashCode();
}
}
And the following Entity using that idClass:
@Entity
@Table(name="domainadmin")
@IdClass(DomainAdminId.class)
@NamedQueries( {
@NamedQuery(name = "DomainAdmin.test", query = "SELECT d FROM DomainAdmin d")
)
public class DomainAdmin implements Serializable {
@Id
@Column(name="domain_name")
private String domainName;
@Id
@Column(name="adminuser")
private String adminUser;
public DomainAdmin() {
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public String getAdminUser() {
return adminUser;
}
public void setAdminUser(String adminUser) {
this.adminUser = adminUser;
}
}
When executing the DomainAdmin.test Named Query I got this error:
could not execute query [select domainadmi0_.adminUser as adminUser1_, domainadmi0_.domainName as domainName1_ from domainadmin domainadmi0_]
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'domainadmi0_.domainName' in 'field list'
In effect, as indicated in the source, the column name is "domain_name" and not "domainName".
The same apply for the other column: adminUser (that should instead be "adminuser"),
This issue is blocking for me, do you have any workaround for the time being?
--
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
16 years, 10 months
[Hibernate-JIRA] Created: (HHH-2709) Informix dialect generates incorrect ALTER TABLE statement
by Ovidiu Feodorov (JIRA)
Informix dialect generates incorrect ALTER TABLE statement
----------------------------------------------------------
Key: HHH-2709
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2709
Project: Hibernate3
Issue Type: Bug
Components: metamodel
Affects Versions: 3.2.4, 3.2.3, 3.2.2, 3.2.1
Environment: Informix Dynamic Server 10.00.UC6, JDBC driver 3.00.JC3
Reporter: Ovidiu Feodorov
org.hibernate.dialect.InformixDialect shipping with Hibernate 3.2.1 - 3.2.4 generates corrupted SQL, at least relative to Informix Dynamic Server 10.00.UC6.
2007-07-02 18:14:47,011 ERROR SchemaExport:274 - Unsuccessful: alter table A add constraint foreign key (B_ID) references collection constraint FK4AA13DBAA4271173 on delete cascade
2007-07-02 18:14:47,011 ERROR SchemaExport:275 - A syntax error has occurred.
This is what the Dialect generates:
alter table A add constraint foreign key ( B_ID) references collection constraint FKBC16C978A4271173 on delete cascade
This is what works:
alter table A add constraint foreign key (B_ID) references collection on delete cascade constraint FKBC16C978A4271173
--
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
16 years, 10 months
[Hibernate-JIRA] Created: (EJB-307) Unable to create the table for a class extending a 2 tables mapped abstract class
by Brice LEPORINI (JIRA)
Unable to create the table for a class extending a 2 tables mapped abstract class
----------------------------------------------------------------------------------
Key: EJB-307
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-307
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.2.1
Environment: JBoss 4.2.0 GA, WinXP SP2, Only using javax.persistence annotations
Reporter: Brice LEPORINI
persistence.xml:
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true" />
</properties>
One main abstract class mapped on 2 tables:
@Entity
@Table(name="T_CRI")
@SecondaryTable(name="T_CRI_FT",
pkJoinColumns=@PrimaryKeyJoinColumn(name="PK_IDCRI", referencedColumnName="PK_IDCRI"))
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class CriFt implements Cri,Identified {
[.......]
}
Deployment with schema export works fine...
Now let's create a new class extending this one:
@Entity
@Table(name="T_CRI_FT_MAINTENANCE")
public class CriFtMaintenance extends CriFt implements Serializable, Identified, Cri {
[......]
}
Now deployment throws an exception:
09:41:23,359 INFO [SessionFactoryImpl] building session factory
09:41:23,437 ERROR [AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: Table T_CRI_FT not found
If Inheritance strategy is anything else than JOINED, there is no problem.
Feel free to contact me in order to get more informations about environment.
--
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
16 years, 10 months
[Hibernate-JIRA] Created: (HHH-2712) OneToOne mapping with PrimaryKeyJoinColumn and CascadeType.ALL throws IdentifierGenerationException
by Colin Smith (JIRA)
OneToOne mapping with PrimaryKeyJoinColumn and CascadeType.ALL throws IdentifierGenerationException
---------------------------------------------------------------------------------------------------
Key: HHH-2712
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2712
Project: Hibernate3
Issue Type: Bug
Environment: Hibernate 3.2.4, Annotations 3.3.0
Reporter: Colin Smith
Customer has a 1-1 mapping with CustomerRiskProfile.
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "SEQUENTIAL_HILO_GENERATOR")
private Long id;
@OneToOne(cascade = CascadeType.ALL)
@PrimaryKeyJoinColumn
private CustomerRiskProfile customerRiskProfile;
CustomerRiskProfile has:
@Id
private Long id;
@OneToOne(mappedBy = "customerRiskProfile")
private Customer customer;
If I create a new Customer and a new CustomerRiskProfile, associate the two, then call session.save(customer), I get:
org.springframework.orm.hibernate3.HibernateSystemException: ids for this class must be manually assigned before calling save(): com.cantorcfds.domain.CustomerRiskProfile; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.cantorcfds.domain.CustomerRiskProfile
Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.cantorcfds.domain.CustomerRiskProfile
at org.hibernate.id.Assigned.generate(Assigned.java:33)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:456)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:334)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:689)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:686)
at com.cantorcfds.dao.HibernateCustomerDao.save(HibernateCustomerDao.java:36)
at com.cantorcfds.domain.TestSchemaLoad.testDataLoad(TestSchemaLoad.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
I would expect Hibernate to generate the Id for the Customer AND the CustomerRiskProfile before trying to save anything?
--
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
16 years, 10 months
[Hibernate-JIRA] Created: (HBX-733) Updated DAO code generation as discussed over the email
by Alex Kalinovsky (JIRA)
Updated DAO code generation as discussed over the email
-------------------------------------------------------
Key: HBX-733
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-733
Project: Hibernate Tools
Type: Patch
Components: hbm2java, ant
Versions: 3.1alpha5
Environment: I have tested the patch on the latest version of Hibernate Tools I got from SVN 2 weeks ago.
Reporter: Alex Kalinovsky
Attachments: dao_generation.patch
This should be a complete implementation of DAO generation according to the design we have discussed over the email. I've tested this on our project so the DAOs should be good to go, but of course a more diverse testing would be needed before releasing it to public. I'm open for recommendations and suggestions, so I see this as the first draft. Below is a list of files and comments. Contact me at kalinovsky(a)yahoo.com.
src/java/org/hibernate/tool/hbm2x
DAONewExporter.java This class is coded mainly to accept additional parameters such as dao package name and provide flexible
file naming that is used by Ant task. It would not be needed if I integrate my changes into GenericExporter.
src/templates/dao
crudDao.ftl template for regeneratable CRUD interface
crudDaoImpl.ftl template for regeneratable CRUD DAO implementation
dao.ftl template for customizable DAO interface that extends CRUD interface
daoImpl.ftl template for customizable DAO implementation that extends CRUD implementation
src/templates/dao/base
dao.ftl base interface for all DAOs
queryDao.ftl base interface for all read-only entities
crudDao.ftl base interface for all editable entities
src/templates/dao/base/hibernate
abstractDao.ftl base implementation of DAO using Hibernate
abstractQueryDao.ftl base implementation of DAO for read-only entities using Hibernate
abstractCrudDao.ftl base implementation of DAO for editable entities using Hibernate
src/testsupport
codegen.properties Test configuration to see DAO generation in action
codegen-build.xml Test build file that generates DAOs for Author and Article and compiles generated code
--
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
16 years, 10 months