[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, 10 months
[Hibernate-JIRA] Created: (HHH-2852) usefull error messages, for instance when schema validation fails
by Eirik Maus (JIRA)
usefull error messages, for instance when schema validation fails
-----------------------------------------------------------------
Key: HHH-2852
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2852
Project: Hibernate3
Issue Type: New Feature
Components: core
Affects Versions: 3.2.0.ga
Reporter: Eirik Maus
Error messages from Hibernate should contain sufficient amount of details to make it possible to locate the problem.
Using hibernate in a large project is a mixed blessing. It does indeed save you from a lot of difficult and tedious work when everything is okay, but errors during startup are almost impossible to locate due to lack of detail. See for instance the following startup error:
[blah, blah, blah .... could not start .... exception ...blah, blah, blah,...]
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [applicationContext-blankett.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Wrong column type: utstedt_dato, expected: date
Caused by:
org.hibernate.HibernateException: Wrong column type: utstedt_dato, expected: date
at org.hibernate.mapping.Table.validateColumns(Table.java:251)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1007)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:807)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:740)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
at no.bbs.common.hibernate.HibernateSessionFactoryBean.afterPropertiesSet(HibernateSessionFactoryBean.java:121)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
.....
I have 3 different hibernate datasources, 8 different *.hbm.xml files from 5 different domain-logic modules, containing in all 9 different columns with that name. Some 15-20 people make modifications to the code base and mappings regularly. It is not so easy to find out who to ask about this problem from the error message provided. Thanks to spring I get an idea of which datasource that failed to start: it prints out which bean that failed creation and where it was defined. Still, it doesn't help me to pinpoint the problem. Why doesn't Configuration even print out which table it is trying to validate? Spending lots of time trying to track down such errors is truly a waste. All the required information was available inside hibernate at the time of the problem, only it wasn't printed out to the user.
Other error messages in hibernate are sometimes poor, too, but this is probably the worst.
At least Configuration must print out the following info:
* table name and mapped class (fully qualified name)
* column name and expected data type (as it does today)
* The URL (or, at least, file name) of the mapping file defining the "problem"
* ... or something else for other sources of mapping info (like annotations), I have no idea what,
Also, the following should really be printed as well
* actual data type found in the schema
* datasource URL
* datasource user name
(The hibernate developers should look to tapestry for how to make deverloper-friendly error diagnostics. A lot of bad things can be (is) said about that project and its leaders, but at least they provide really really nice error messages that directly points out your error so you don't have to spend hours and hours trying to analyze/guess what and where things went 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
16 years, 10 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
16 years, 11 months
[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
16 years, 11 months
[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
16 years, 11 months
[Hibernate-JIRA] Created: (HHH-2739) 'illegal attempt to dereference collection' when referencing a single-valued association in an implicit join
by Martin Kouba (JIRA)
'illegal attempt to dereference collection' when referencing a single-valued association in an implicit join
------------------------------------------------------------------------------------------------------------
Key: HHH-2739
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2739
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4.sp1, 3.2.4, 3.2.3
Environment: I have found that behaviour in version 3.2.4.sp1 and 3.2.3 (I didn't test 3.2.4 pre sp1)
Database: ORACLE 10g
Reporter: Martin Kouba
After upgrading to the latest Hibernate version I got this error.
I try to use a statement like this
from cat c where c.mate.id = 13
the expected resulting SQL should be something like
SELECT * FROM CAT C WHERE C.MATE_ID = 13
which is much more performant than making a join
from cat c join c.mate m where m.id = 13
which would result in something like that
SELECT * FROM CAT C INNER JOIN MATE M ON C.MATE_ID = M.ID WHERE M.ID = 13
This works as expected in 3.1.3, 3.2.0 and 3.2.2
It doesn't work with version 3.2.3 and with 3.2.4.sp1.
As test case you can take the example from the documentation chapter 5.1.16
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="eg">
<class name="Cat" table="CATS">
<id name="id" column="uid" type="long">
<generator class="hilo"/>
</id>
<property name="birthdate" type="date"/>
<property name="color" not-null="true"/>
<property name="sex" not-null="true"/>
<property name="weight"/>
<many-to-one name="mate"/>
<set name="kittens">
<key column="MOTHER"/>
<one-to-many class="Cat"/>
</set>
<joined-subclass name="DomesticCat" table="DOMESTIC_CATS">
<key column="CAT"/>
<property name="name" type="string"/>
</joined-subclass>
</class>
<class name="eg.Dog">
<!-- mapping for Dog could go here -->
</class>
</hibernate-mapping>
c = new Cat();
c.setMate(new Cat());
c.persist();
int id = c.getId();
List results = session.createQuery("from Cat as c where c.mate.id = 16).list();
according to manual section 14.5 this should work
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#queryhql-i...
Ok, I hope this is clear enough and the test case is clear enough as well.
This is a major stopper for an upgrade. I have reported that on June 11th
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2667
But it seems that others used the same case to report a similar issue regarding automatic joins.
According to Christian Bauer automatic joins are no longer supported, closed the case and told me to reopen it again.
So to all others please do not add comments to this case if it is not about it. And to the Hibernate developers: Greate work you are doing but please I think the issue was clear when I reported it the first time. It is quite easy to reproduce and occurs quite often in a medium size project.
Gratitude
Martin
--
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, 11 months
[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
16 years, 11 months