[Hibernate-JIRA] Created: (HHH-2871) can't specify property of the element in the collection
by Vlad Rechkalov (JIRA)
can't specify property of the element in the collection
-------------------------------------------------------
Key: HHH-2871
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2871
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.5
Reporter: Vlad Rechkalov
Attachments: SQLQueryParser.java
In according to Hibernate documentation (topic 16.1.4.1. Alias and property references) collection properties can be specified a few ways:
All properties of the the collection {[aliasname].*}
All properties of the element in the collection {[aliasname].element.*}
Property of the element in the collection {[aliasname].element.[propertyname]}
But the last way doesn't work.
Example:
There are two entities: Program and Document. Program has one-to-many inverse collection of Documents.
Program
int getId()
List<Document> getDocuments() // one-to-many inverse collection
Document
int getId()
String getTitle()
Program getParent() // many-to-one association
Trying to select Program and fetch collection of Documents:
select
p.id as {p.id},
d.program_id as {d.key},
d.id as {d.element},
d.id as {d.element.id},
d.title as {d.element.title},
d.program_id as {d.element.program}
from ...
SQLQuery q = session.createSQLQuery
q.addEntity("p", Program.class);
q.addJoin("d", "p.documents");
q.list(); // throws exception
There is a simple way to fix this bug:
class SQLQueryParser
method resolveCollectionProperties
instead of code (line 140)
else if ( "element.*".equals( propertyName ) ) {
return resolveProperties( aliasName, "*" );
}
write
else if( propertyName.startsWith(ELEMENT_PREFIX) ) {
return resolveProperties( aliasName, propertyName.substring(ELEMENT_PREFIX.length()) );
}
comments: ELEMENT_PREFIX is defined as
private static final String ELEMENT_PREFIX = "element.";
The fixed file is attached.
--
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, 2 months
[Hibernate-JIRA] Created: (HHH-2750) Oracle9i dialect do not support SequenceStyleGenerator
by Richard Lee (JIRA)
Oracle9i dialect do not support SequenceStyleGenerator
------------------------------------------------------
Key: HHH-2750
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2750
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3
Environment: Oracle9i
Reporter: Richard Lee
Attachments: dynamicMap.hbm.xml
In the hibernate.cfg.xml set :
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hbm2ddl.auto">update</property>
Java Code:
private void createSubnet() {
Session session = HibernateSessionFactory.getSession();
HashMap<String, Object> subNet = new HashMap<String, Object>();
subNet.put("ISDELETE", Boolean.FALSE);
Timestamp now = DateUtil.getNow();
subNet.put("CREATE_TIME", now);
subNet.put("LAST_MODIFY_TIME", now);
Transaction tx = session.beginTransaction();
session.save("SUB_NET", subNet);
tx.commit();
session.flush();
HibernateSessionFactory.closeSession();
}
Exception:
Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.dialect.Dialect.getCreateSequenceStrings(Ljava/lang/String;II)[Ljava/lang/String;
at org.hibernate.id.enhanced.SequenceStructure.sqlCreateStrings(SequenceStructure.java:97)
at org.hibernate.id.enhanced.SequenceStyleGenerator.sqlCreateStrings(SequenceStyleGenerator.java:168)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:1051)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:140)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
at com.ultrapower.oe.util.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:89)
at com.ultrapower.oe.util.HibernateSessionFactory.getSession(HibernateSessionFactory.java:63)
--
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, 2 months
[Hibernate-JIRA] Created: (HHH-2813) CacheableFileTest Failing Because Mapping File Doesn't Exist
by James Carman (JIRA)
CacheableFileTest Failing Because Mapping File Doesn't Exist
------------------------------------------------------------
Key: HHH-2813
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2813
Project: Hibernate3
Issue Type: Bug
Components: testsuite
Reporter: James Carman
Attachments: CacheaableFileTest.patch
When running the test suite from a fresh trunk checkout, I get one little failing test in the maven 2 based build:
junit.framework.AssertionFailedError
at org.hibernate.test.cfg.CacheableFileTest.setUp(CacheableFileTest.java:26)
at org.hibernate.junit.UnitTestCase.runBare(UnitTestCase.java:34)
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 changed the code just a bit (patch attached) to get it to work. This could be a platform issue (I'm on Windows XP Pro SP2), but it'd be nice if it worked on all platforms. Here's what I changed so you don't have to open the patch:
mappingFile = new File( getClass().getClassLoader().getResource( MAPPING ).getFile() );
changes to:
mappingFile = new File( getClass().getClassLoader().getResource( MAPPING ).toURI() );
--
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, 2 months
[Hibernate-JIRA] Created: (HHH-2822) timestamp extraction functions do not work in SAPDBDialect
by Yossi Tamari (JIRA)
timestamp extraction functions do not work in SAPDBDialect
----------------------------------------------------------
Key: HHH-2822
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2822
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5, 3.2.4.sp1, 3.2.4, 3.2.3, 3.2.2, 3.2.1, 3.2.0.ga, 3.2.0.cr5, 3.2.0.cr4, 3.2.0.cr3, 3.2.0.cr2, 3.2.0 cr1, 3.1.3, 3.2.0.alpha2, 3.2.0.alpha1, 3.1.2, 3.1.1, 3.1, 3.1 rc3, 3.1 rc2, 3.1 rc 1, 3.1 beta 2, 3.1 beta 1, 3.0.5, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0 final, 3.0 rc 1, 3.0 beta 4, 3.0 beta 3, 3.0 beta 2, 3.0 beta 1, 3.0 alpha
Environment: SAPDB 7.6
Reporter: Yossi Tamari
Priority: Minor
There is no registerFunction in the SAPDBDialect for the date extraction SQL functions (extract, day, hour...). Therefore, the inherited registration from Dialect are in effect. However, they all map to extract, which is no supported in SAPDB.
The correct implementation is to register the following functions in SAPDBDialect.java:
registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "second(?1)") );
registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "minute(?1)") );
registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "hour(?1)") );
registerFunction( "day", new SQLFunctionTemplate(Hibernate.INTEGER, "day(?1)") );
registerFunction( "month", new SQLFunctionTemplate(Hibernate.INTEGER, "month(?1)") );
registerFunction( "year", new SQLFunctionTemplate(Hibernate.INTEGER, "year(?1)") );
registerFunction( "extract", new SQLFunctionTemplate(Hibernate.INTEGER, "?1(?3)") );
--
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, 2 months
[Hibernate-JIRA] Created: (HHH-2840) Externalizing named HQL queries with DML is impossible
by Dimitri Lubenskyy (JIRA)
Externalizing named HQL queries with DML is impossible
------------------------------------------------------
Key: HHH-2840
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2840
Project: Hibernate3
Issue Type: Bug
Environment: Hibernate Core 3.2.5
Reporter: Dimitri Lubenskyy
Externalizing the update HQL query into the XML file e.g.
....
</class>
<query name="hqlResetNotificationDatePlc">
<![CDATA[update ServiceEvents se set se.notificationNeeded=0 where se.notificationNeeded=1]]>
</query>
</hibernate-mapping>
Throws the exception:
org.hibernate.hql.ast.ErrorCounter: line 1:1: unexpected token: hqlResetNotificationDateRc
line 1:1: unexpected token: hqlResetNotificationDateRc
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:171)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:248)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
--
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, 2 months
[Hibernate-JIRA] Created: (HHH-2842) Problem with instantiating components
by Lanna Kim (JIRA)
Problem with instantiating components
-------------------------------------
Key: HHH-2842
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2842
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5ga, DB2 8
Reporter: Lanna Kim
Attachments: quickfix.zip, school.zip
Hi,
I am working on a project migrating a legacy application into J2EE environment using Hibernate.
Although it has fairly complicated class hierarchy and table structures, we have managed to migrate most of features successfully, thanks to the flexibility of Hibernate. (Thank you for the great work!)
However, we have one issue with instantiating dependent objects.
Sometimes only parent class knows how to instantiate its dependent objects properly, so these objects need to be created by their parent class.
For example, the following persistent class Student has a dependent object studentInfo, which is mapped as as component in the mapping file.
--------------------------------------------------
public class Student {
private Long id;
private StudentInfo studentInfo;
public Student() {
// instantiate StudentInfo object here with some additional information.
studentInfo = new StudentInfo(SchoolHelper.lookupType("C"));
}
// ...
}
--------------------------------------------------
public class StudentInfo {
private String description;
private transient String typeA;
private transient String typeB;
public StudentInfo() {
}
public StudentInfo(String type) {
this.typeA = SchoolHelper.getTypeA(type);
this.typeB = SchoolHelper.getTypeB(type);
}
// ...
--------------------------------------------------
<class name="school.Student" table="STUDENT">
<id name="id" column="STUDENT_ID">
<generator class="native"/>
</id>
<component name="studentInfo" class="school.StudentInfo">
<property name="description" column="SI_DESC" />
</component>
</class>
--------------------------------------------------
Only 'description' member is mapped to a database column and other transient members of StudentInfo aren't. These transient members can be set only by using the information passed from its parent class, Student.
However, when a Student object is loaded from database, this information (typeA and typeB) becomes null, because the default constructor StudentInfo() is used by Hibernate, and then Student.setStudentInfo() is called to replace the existing (but properly instantiated) studentInfo object.
I know it is a Hibernate requirement for all persistent classes to have no-arg default constructors.
This is fine, but is it true for all dependent objects as well?
Some of our depedent objects are contained in both persistent classes and business logic classes and it is very difficult to separate them.
It would be great if Hibernate supports either of following features:
1) <property> can accept a dotted notaton for its name, so that we can access directly the member of the depedent object without having <component>.
i.e.
<property name="studentInfo.description" column="SI_DESC" />
<!-- this will call getStudentInfo().setDescription(). -->
or,
2) <component> has an option to indicate to reuse the existing instance instead of always creating a new one.
i.e.
<component name="studentInfo" reuse="true" class="school.StudentInfo>
...
</component>
<!-- the existing studentInfo object will be used (unless it is null), instead of creating one with its default constructor -->
I have attached student.zip to indicate this issue and quickfix.zip for the (rough) hibernate fix so that ComponentType reuses the existing value unless it is null.
Any advice or comment would be appreciated.
--
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, 2 months