[Hibernate-JIRA] Created: (HHH-2159) Query that previously worked in 3.2.0CR2 does not work anymore
by Andy Dale (JIRA)
Query that previously worked in 3.2.0CR2 does not work anymore
---------------------------------------------------------------
Key: HHH-2159
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2159
Project: Hibernate3
Type: Bug
Versions: 3.2.0.ga
Environment: hibernate 3.2.0GA, PostgreSQL 8.1.4 (using build 407 of the JDBC driver). JDK 1.5.0_06, JBoss 4.0.4GA, Operating system is Fedora Core 5
Reporter: Andy Dale
Attachments: hibernate_testcase.tar.gz
First off i do not know if this bug belongs to the Hibernate3(core) or Hibernate EntityManger branch, but have entered it against core because that is where the exception occurs (in org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements).
I have a relativley simple entity setup up to test a proof of concept. Persisting the data to the database is not a problem in the new version 3.2.0.GA, but the problems occurs when trying to perform a query on the persisted data, the very same query works with 3.2.0CR2 but gives a nullPointException in 3.2.0GA.
I have attached the java source for the entities + session bean (in hibernate_testcase.tar.gz/entities file) and the java class (in hibernate_testcase.tar.gz/service file) that is used to persist and query the data, and because this was only meant to be a proof of concept i have also included the .ear archive as apart from the entity definitions and session bean the only other thing it contains is a JBoss .sar archive which calls the static persist and query methods in the session bean (service test.testcase). Please note to use the .ear archive you need a datasource called Postgres_Test
--
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, 12 months
[Hibernate-JIRA] Created: (HHH-2211) A createQuery() caused ORA-00904 error
by sodia (JIRA)
A createQuery() caused ORA-00904 error
--------------------------------------
Key: HHH-2211
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2211
Project: Hibernate3
Type: Bug
Components: query-hql
Versions: 3.2.0.ga
Environment: JDK1.5.0+Eclipse3.2.1+Hibernate3.2.0.ga+Oracle9.2.0+WinXp(Prof)Sp2
Reporter: sodia
Priority: Trivial
Attachments: hiber-grammar-sql-and-errlog.zip, hiber-grammar-test.zip
I want to try the following sql under hibernate,it failed.
(The project is build on the basis of hibernate3.2's tutorial)
String hqlAlias =
"insert into EventHistory ( id, date, title )" +
" select id, date, title from Event e" +
" where e.title like 'BUY%'" +
" and exists" +
" ( select 1 from PersonEvent p" +
" where p.id=e.id)";
int resultAlias = session.createQuery(hqlAlias).executeUpdate();
But it works nice under sqlplus.
INSERT INTO EVENTS_HISTORY
SELECT * FROM EVENTS
WHERE TITLE LIKE 'BUY%'
AND EXISTS
( SELECT 1 FROM PERSON_EVENT
WHERE EVENT_ID=EVENTS.EVENT_ID);
The 4 lines of error log is like this:
15:33:29,906 DEBUG SQL:393 - insert into EVENTS_HISTORY ( EVENT_ID, EVENT_DATE, title ) select event0_.EVENT_ID as col_0_0_, event0_.EVENT_DATE as col_1_0_, event0_.title as col_2_0_ from EVENTS event0_ where (event0_.title like 'BUY%') and (exists (select 1 from PERSON_EVENT personeven1_ where personeven1_.EVENT_ID=EVENTS.EVENT_ID))
Hibernate: insert into EVENTS_HISTORY ( EVENT_ID, EVENT_DATE, title ) select event0_.EVENT_ID as col_0_0_, event0_.EVENT_DATE as col_1_0_, event0_.title as col_2_0_ from EVENTS event0_ where (event0_.title like 'BUY%') and (exists (select 1 from PERSON_EVENT personeven1_ where personeven1_.EVENT_ID=EVENTS.EVENT_ID))
15:33:29,984 WARN JDBCExceptionReporter:71 - SQL Error: 904, SQLState: 42000
15:33:29,984 ERROR JDBCExceptionReporter:72 - ORA-00904: "EVENTS"."EVENT_ID": 无效的??符
Is there any wrong with the hql,or it's alias?
Thanks to anyone who pay attetion to this trivial question which I search the forum and google without solutions.
Or if I missed them,I would be grateful that you might tell me where can I find the right answer to fix this hql grammar error.
--
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
17 years
[Hibernate-JIRA] Created: (HHH-2110) Proxied object causes ClassCastException when method returns 'this' in a composite hierarchy
by Philip Nightingale (JIRA)
Proxied object causes ClassCastException when method returns 'this' in a composite hierarchy
--------------------------------------------------------------------------------------------
Key: HHH-2110
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2110
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.0.5
Environment: Hibernate 3, any database (test case uses HSQL, issue found using Oracle)
Reporter: Philip Nightingale
Attachments: HibernateClassCastExceptionTest.zip
If a proxied object has a method that returns 'this' and the proxy type extends the same base class as the target object and the return type of the method is the target class type then a ClassCastException is thrown.
The error can be tracked down to the method CGLibLazyInitializer::intercept(Object, Method, Object[], MethodProxy).
In this method, if the object returned from the method call on the target object is the same as the target object, then instead of returning the object itself the proxy is returned. This is fine in most cases, but in the special case described, in which the proxy extends a base class that is also extended by the target class, then the CCE occurs.
In the submitted test case I have a simple composite hierarchy with an abstract base type and two concrete subtypes. Either type can contain children, but only one can be the root of the hierarchy (and cannot itslef be a child). There is a many-to-one relationship defined from the sub-type that may be a child to the base class.
The submitted test case is configured to use Hypersonic DB so hsqldb.jar is required on the classpath.
Further details and code snippets from the original code that caused the exception are posted on the Hibernate user forum (topic "ClassCastException with CGLIB Lazy Initialization")
--
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
17 years
[Hibernate-JIRA] Created: (HHH-2048) Incomplete MappingException at org.hibernate.mapping.SimpleValue
by Diego Pires Plentz (JIRA)
Incomplete MappingException at org.hibernate.mapping.SimpleValue
----------------------------------------------------------------
Key: HHH-2048
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2048
Project: Hibernate3
Type: Improvement
Versions: 3.2.0.cr4
Reporter: Diego Pires Plentz
When a mapped class has a wrong type, an exception is throwed, but it doesnt say nothing about what class/table is mapped wrongly.
public Type getType() throws MappingException {
if (typeName==null) {
throw new MappingException("No type name");
}
Type result = TypeFactory.heuristicType(typeName, typeParameters);
if (result==null) {
String msg = "Could not determine type for: " + typeName;
if(columns!=null && columns.size()>0) {
msg += ", for columns: " + columns;
}
throw new MappingException(msg);
}
return result;
}
Can become something like this...
public Type getType() throws MappingException {
if (typeName==null) {
throw new MappingException("No type name");
}
Type result = TypeFactory.heuristicType(typeName, typeParameters);
if (result==null) {
String msg = "Could not determine type for: " + typeName;
if(table != null){
msg += ", at table: " + table.getName();
}
if(columns!=null && columns.size()>0) {
msg += ", for columns: " + columns;
}
throw new MappingException(msg);
}
return result;
}
--
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
17 years
[Hibernate-JIRA] Created: (HHH-2436) Incorrect SQL generation for some select statements with "group by"
by Joseph Marques (JIRA)
Incorrect SQL generation for some select statements with "group by"
-------------------------------------------------------------------
Key: HHH-2436
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2436
Project: Hibernate3
Type: Bug
Versions: 3.2.1
Reporter: Joseph Marques
JPQL was:
SELECT res.resourceType, count(res.resourceType)
FROM ResourceGroup rg JOIN rg.resources res
WHERE rg.id = :id
GROUP BY res.resourceType
It translated to:
select
resource2_.RESOURCE_TYPE_ID as col_0_0_,
count(resource2_.RESOURCE_TYPE_ID) as col_1_0_,
resourcety3_.ID as ID376_,
resourcety3_.NAME as NAME376_,
resourcety3_.DESCRIPTION as DESCRIPT3_376_,
resourcety3_.CATEGORY as CATEGORY376_,
resourcety3_.PLUGIN as PLUGIN376_,
resourcety3_.CTIME as CTIME376_,
resourcety3_.MTIME as MTIME376_,
resourcety3_.PARENT_RESOURCE_TYPE_ID as PARENT8_376_,
resourcety3_.PLUGIN_CONFIG_DEF_ID as PLUGIN9_376_,
resourcety3_.RES_CONFIG_DEF_ID as RES10_376_
from
public.ON_RESOURCE_GROUP resourcegr0_
inner join
public.ON_RESOURCE_GROUP_RES_MAP resources1_
on resourcegr0_.ID=resources1_.RESOURCE_GROUP_ID
inner join
public.ON_RESOURCE resource2_
on resources1_.RESOURCE_ID=resource2_.ID
inner join
public.ON_RESOURCE_TYPE resourcety3_
on resource2_.RESOURCE_TYPE_ID=resourcety3_.ID
where
resourcegr0_.DTYPE in (
'COMPATIBLE', 'MIXED'
)
and resourcegr0_.ID=?
group by
resource2_.RESOURCE_TYPE_ID
The message was:
"ERROR main org.hibernate.util.JDBCExceptionReporter - ERROR: column "resourcety3_.id must appear in the GROUP BY caluse or be used in an aggregate function"
My issue with this is that I only want to select a single object (along with the count of that object when grouped), but the generated SQL seems to be selecting two different objects - resource2_ and resourcety3_. The jdbc error message is perfectly correct; it's the translated SQL that seems a bit off.
Maybe the JPQL syntax I want to use is not supported? Or perhaps I'm just doing something wrong?
--
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
17 years
[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
17 years
[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
17 years
[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
17 years