[Hibernate-JIRA] Created: (ANN-590) Table name problem
by Eddie Man (JIRA)
Table name problem
------------------
Key: ANN-590
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-590
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.2.1
Reporter: Eddie Man
Priority: Critical
Attachments: src.zip
Problem:
When I run the test.Main in the attachment, an mapping exception thrown while passing the annotation:
Exception in thread "main" org.hibernate.MappingException: Unable to find column with logical name: customerID in ShoppingBasket
at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:383)
at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:88)
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:63)
at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at test.Main.main(Main.java:19)
But when I change the table name of ShoppingBaskets to "Basket", then the problem solved.
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (ANN-683) AnnotationConfiguration hashCode collisions produce random binding failures
by Tim Smith (JIRA)
AnnotationConfiguration hashCode collisions produce random binding failures
---------------------------------------------------------------------------
Key: ANN-683
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-683
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate 3.2.4, J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223-20070426, AIX 5.3
Reporter: Tim Smith
Priority: Blocker
Attachments: hashCode_bug_fix.patch
The method AnnotationConfiguration.processFkSecondPassInOrder creates a Comparator that results in FkSecondPass objects being inadvertently removed from the secondPasses list due to an incorrect hashCode comparison.
Lines 398 - 401 contain this comparison of hashCodes:
else if ( f1.hashCode() == f2.hashCode() ) {
compare = 0;
}
FkSecondPass uses Object.hashCode which has the JavaDoc comment:
* As much as is reasonably practical, the hashCode method defined by
* class <tt>Object</tt> does return distinct integers for distinct
* objects. (This is typically implemented by converting the internal
* address of the object into an integer, but this implementation
* technique is not required by the
* Java<font size="-2"><sup>TM</sup></font> programming language.)
In my application I have seen random failures during startup of the application due to the fact that hashCodes for two FkSecondPass instances are the same, the result is that the FkSecondPass.secondPass method is never called and the FK is never bound, resulting in a error like:
org.hibernate.MappingException: Foreign key (FK76A5E7CBCC5EDAA3:CLIENT [])) must have same number of columns as the referenced primary key (CLIENTAPPRC98BF18C [OBJECTID])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:90)
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:73)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1263)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:416)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
As you can see the FK column on the owning table is empty (as TableBinder.bindFk is not called).
This is a blocker for my application as I can not guarantee when the application will boot. It is entirely dependent on the memory state and implementation of the JVM as to whether or not a hashCode collision occurs.
The patch is simple, a one-liner, to replace the hashCode comparison with an object equality comparison:
else if ( f1 == f2 ) {
compare = 0;
}
I have attached a patch for AnnotationConfiguration to fix this issue.
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (HBX-938) Graphviz support in hbm2doc does not support Any mappings
by Matt Read (JIRA)
Graphviz support in hbm2doc does not support Any mappings
---------------------------------------------------------
Key: HBX-938
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-938
Project: Hibernate Tools
Issue Type: Bug
Components: doc
Affects Versions: 3.2beta9
Reporter: Matt Read
Ran hbm2doc from with Maven using the following config:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="maven.test.classpath" />
<hibernatetool destdir="target/hbm2doc">
<configuration
configurationfile="src/test/resources/framepersistence/hibernate.cfg.xml" />
<hbm2doc>
<property key="dot.executable" value="c:/work/apps/Graphviz/Graphviz/bin/dot.exe"/>
</hbm2doc>
</hibernatetool>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Which produced the following error - my mappings contain <any> tags.
12:05:55 ERROR freemarker.runtime -
Method public java.lang.String org.hibernate.tool.hbm2x.Cfg2HbmTool.getHibernateTypeName(org.hibernate.mapping.Property) threw an exception when invoked on org.
hibernate.tool.hbm2x.Cfg2HbmTool@7348e
The problematic instruction:
----------
==> if c2h.getHibernateTypeName(property)?exists [on line 62, column 6 in dot/entitygraph.dot.ftl]
in user-directive propertyEdges [on line 32, column 3 in dot/entitygraph.dot.ftl]
----------
Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.Cfg2HbmTool.getHibernateTypeName(org.hibernate.mapping.Prope
rty) threw an exception when invoked on org.hibernate.tool.hbm2x.Cfg2HbmTool@7348e
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.BuiltIn$existsBI._getAsTemplateModel(BuiltIn.java:635)
at freemarker.core.BuiltIn$existsBI.isTrue(BuiltIn.java:646)
at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
at freemarker.core.Environment.visit(Environment.java:351)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Macro$Context.runMacro(Macro.java:164)
at freemarker.core.Environment.visit(Environment.java:537)
at freemarker.core.UnifiedCall.accept(UnifiedCall.java:128)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
at freemarker.core.Environment.visit(Environment.java:351)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:231)
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:247)
at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67)
at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:97)
at org.hibernate.tool.hbm2x.GenericExporter$1.process(GenericExporter.java:30)
at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:126)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
at org.hibernate.tool.hbm2x.DocExporter.generateDot(DocExporter.java:182)
at org.hibernate.tool.hbm2x.DocExporter.doStart(DocExporter.java:151)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:183)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.UnsupportedOperationException: accept on org.hibernate.mapping.Any([org.hibernate.mapping.Column(cmvSourceTable), org.hibernate.mapping.Col
umn(cmvSourceSID)])
at org.hibernate.tool.hbm2x.visitor.DefaultValueVisitor.handle(DefaultValueVisitor.java:40)
at org.hibernate.tool.hbm2x.visitor.DefaultValueVisitor.accept(DefaultValueVisitor.java:87)
at org.hibernate.mapping.Any.accept(Any.java:67)
at org.hibernate.tool.hbm2x.Cfg2HbmTool.getHibernateTypeName(Cfg2HbmTool.java:380)
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:583)
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
... 63 more
[hibernatetool] An exception occurred while running exporter #2:hbm2doc (Generates html schema documentation)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.tool.hbm2x.ExporterException: Error while processing template dot/entitygraph.dot.ftl
[hibernatetool] freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.Cfg2HbmTool.getHibernateTypeName(org.hiberna
te.mapping.Property) threw an exception when invoked on org.hibernate.tool.hbm2x.Cfg2HbmTool@7348e
[hibernatetool] java.lang.UnsupportedOperationException: accept on org.hibernate.mapping.Any([org.hibernate.mapping.Column(cmvSourceTable), org.hibernate.mappin
g.Column(cmvSourceSID)])
--
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
18 years, 1 month
[Hibernate-JIRA] Commented: (HHH-1512) Problem to lock a row in a DB2 database with LockMode UPGRADE
by Sridhar Ramachandran (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1512?page=c... ]
Sridhar Ramachandran commented on HHH-1512:
-------------------------------------------
Hi,
I encountered this issue while running a concurrency test on DB2. In this test, two threads execute the following pseudo-code
<Get a new session>
<Open a transaction>
System.out.println("Waiting to lock");
session.load(<some class name>, <some PK>, LockMode.UPGRADE)
System.out.println("Got a lock");
<sleep for 10 seconds>
<do an update on the record>
<Commit the transaction>
<Close the session>
System.out.println("Completed transaction");
If I launch these threads with a 5 second gap, both of them get the lock.
Thread 1 - Waiting to lock
Thread 1 - Got a lock
... after 5 seconds
Thread 2 - Waiting to lock
Thread 2 - Got a lock
... after 5 seconds
Thread 1 - Completed transaction
... after 5 seconds
Thread 2 - Throws Exception
The Exception is a LockAcquisitionException. I have seen two types of exceptions
TYPE 1:
org.hibernate.exception.LockAcquisitionException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:82)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
...
Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -911, SQLSTATE: 40001, SQLERRMC: 2
at com.ibm.db2.jcc.b.rc.b(rc.java:3180)
at com.ibm.db2.jcc.a.eb.i(eb.java:227)
at com.ibm.db2.jcc.a.eb.a(eb.java:183)
at com.ibm.db2.jcc.a.eb.a(eb.java:34)
at com.ibm.db2.jcc.a.s.a(s.java:30)
at com.ibm.db2.jcc.a.h.Gb(h.java:325)
at com.ibm.db2.jcc.b.rc.R(rc.java:3022)
at com.ibm.db2.jcc.a.d.f(d.java:1070)
at com.ibm.db2.jcc.b.r.a(r.java:191)
at com.ibm.db2.jcc.b.rc.c(rc.java:302)
at com.ibm.db2.jcc.b.rc.next(rc.java:277)
at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:135)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 8 more
TYPE 2:
Exception in thread "main" org.hibernate.exception.LockAcquisitionException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:82)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
...
Caused by: com.ibm.db2.jcc.b.vd: Non-atomic batch failure. The batch was submitted, but at least one exception occurred on an individual member of the batch. Use getNextException() to retrieve the exceptions for specific batched elements.
at com.ibm.db2.jcc.b.i.a(i.java:390)
at com.ibm.db2.jcc.b.ad.b(ad.java:2863)
at com.ibm.db2.jcc.b.ad.a(ad.java:2632)
at com.ibm.db2.jcc.b.ad.executeBatch(ad.java:2444)
at com.ibm.db2.jcc.b.ad.executeBatch(ad.java:1329)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeBatch(DelegatingPreparedStatement.java:205)
at com.oatsystems.util.SimpleStatement.executeBatch(SimpleStatement.java:131)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 18 more
---
I then changed the DB2Dialect to a point to an implementation suggested in http://forum.hibernate.org/viewtopic.php?t=954639&highlight=db2+lock+upgrade:
public class DB2Dialect extends org.hibernate.dialect.DB2Dialect {
public String getForUpdateString() {
return " for update with rr";
}
}
Now, the lock behaves like a pessimistic lock.
Thread 1 - Waiting to lock
Thread 1 - Got a lock
... after 5 seconds
Thread 2 - Waiting to lock
... after 5 seconds
Thread 1 - Got a lock
Thread 2 - Completed transaction
... after 5 seconds
Thread 2 - Completed transaction
The second transaction gets the lock on the row only after the first transaction is committed.
In SQL Server and Oracle, I think two transactions can not get locks of the LockMode.UPGRADE level at the same time on the same row. It will be great if DB2 also behaves the same way.
I went though the 7 statements mentioned in the previous comments, and my results match those of Milosz:
1) for update with rr (Old version): Pessimistic lock
2) for update with rs: Pessimistic lock
3) for update with cs: No Lock
4) for read only with rs (Current version): Optimistic lock.
5) for read only with rr use and keep update locks: Pessimistic lock
6) for read only with rs use and keep update locks: Pessimistic lock
7) for read only with rr use and keep exclusive locks: Pessimistic lock
Can we change the getForUpdateString() to one of 1, 2, 5, 6 or 7?
Regards,
Sridhar.
> Problem to lock a row in a DB2 database with LockMode UPGRADE
> -------------------------------------------------------------
>
> Key: HHH-1512
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1512
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1
> Environment: DB2 v8.2, Hibernate 3.1 and higher
> Reporter: Peter Potthoff
> Assignee: Steve Ebersole
> Attachments: locks.txt
>
> Original Estimate: 1 hour
> Remaining Estimate: 1 hour
>
> Using the LockMode UPGRADE to lock a row in the database, this will result in
> a sql-statement: select ID from <schema>.<table> where ID =? and version =? for read only with rs
> This statement produces a shared lock and cannot be used for pessimistic locking because
> this kind of lock won't stop a concurrent thread from accessing the data.
> The source of the class DB2Dialect.java was changed from release 1.34 to 1.35:
> http://cvs.sourceforge.net/viewcvs.py/hibernate/Hibernate3/src/org/hibern...
> and from 1.33 to 1.34
> http://cvs.sourceforge.net/viewcvs.py/hibernate/Hibernate3/src/org/hibern...
> Please take a look at: HHH-378 and http://forum.hibernate.org/viewtopic.php?t=954639&highlight=db2+lock+upgrade
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (EJB-341) Trying to create unexisting named query set the transaction to rollback
by Frederic Zgud (JIRA)
Trying to create unexisting named query set the transaction to rollback
-----------------------------------------------------------------------
Key: EJB-341
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-341
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Environment: Hibernate Core 3.2.2 GA
Hibernate EntityManager 3.3.1 GA
Reporter: Frederic Zgud
Trying to create a named query that doesn't exist raises a PersistenceException, instead of the IllegalArgumentException specified in JPA ( http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.htm... ), and sets the current transaction to rollback. This is a non sens.
Source code of AbstractEntityManagerImpl :
...
public Query createNamedQuery(String name) {
//adjustFlushMode();
try {
return new QueryImpl( getSession().getNamedQuery( name ), this );
}
catch (HibernateException he) {
throwPersistenceException( he );
return null;
}
}
The exception is raised in class AbstractSessionImpl (hibernate 3 project) :
...
public Query getNamedQuery(String queryName) throws MappingException {
errorIfClosed();
NamedQueryDefinition nqd = factory.getNamedQuery( queryName );
final Query query;
if ( nqd != null ) {
String queryString = nqd.getQueryString();
query = new QueryImpl(
queryString,
nqd.getFlushMode(),
this,
getHQLQueryPlan( queryString, false ).getParameterMetadata()
);
query.setComment( "named HQL query " + queryName );
}
else {
NamedSQLQueryDefinition nsqlqd = factory.getNamedSQLQuery( queryName );
if ( nsqlqd==null ) {
>>> throw new MappingException( "Named query not known: " + queryName ); <<<<< There
}
query = new SQLQueryImpl(
nsqlqd,
this,
factory.getQueryPlanCache().getSQLParameterMetadata( nsqlqd.getQueryString() )
);
query.setComment( "named native SQL query " + queryName );
nqd = nsqlqd;
}
initQuery( query, nqd );
return query;
}
...
Maybe the line
>>> throw new MappingException( "Named query not known: " + queryName ); <<<<< There
could be replaced by
throw new MappingNotFoundException( "Named query not known: " + queryName );
or another MappingException subclass and this exception catched in AbstractEntityManagerImpl :
public Query createNamedQuery(String name) {
//adjustFlushMode();
try {
return new QueryImpl( getSession().getNamedQuery( name ), this );
}
catch (MappingNotFoundException mnfe) {
throw new IllegalArgumentException( mnfe );
}
catch (HibernateException he) {
throwPersistenceException( he );
return null;
}
}
leaving the transaction open.
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (HHH-3147) Reading resultsets from tables and stored procedures.
by Krashan Brahmanjara (JIRA)
Reading resultsets from tables and stored procedures.
-----------------------------------------------------
Key: HHH-3147
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3147
Project: Hibernate3
Issue Type: Improvement
Environment: 3.2.6ga
Reporter: Krashan Brahmanjara
Hi
I see that Hibernate can't read a results from procedure if results field names are not known.
For example on Informix when procedure return results WITH RESUME all fields got name "(expression)"
and finally result is list of empty Objects.
I found that Hibernate try read all results by name f.e. rs.getInt("name") but resultsets can be also read column byId
which is safe and probably faster. I think that reading byId can be great improvement
for example return-property "columnId" would be solution
<return-property name="idGrub" columnId="1"/>
BTW
InformixDialect.java need few lines of code to support stored procedures like below. It work.
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
return col;
}
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
boolean isResultSet = ps.execute();
while (!isResultSet && ps.getUpdateCount() != -1) {
isResultSet = ps.getMoreResults();
}
return ps.getResultSet();
}
Test case for stored procedures
java code:
es = session.getNamedQuery("aa3_SP");
result = es.list();
for (int idx = 0; idx < result.size(); idx++) {
Object resultList = result.get(idx); // result return a list of empty Objects
}
named query :
<sql-query name="aa2_SP" callable="true">
<![CDATA[{call aa2() }]]>
</sql-query>
spl:
CREATE PROCEDURE aa2() RETURNING INTEGER, CHAR(10), CHAR(60), SMALLINT;
DEFINE a_id INTEGER;
DEFINE a_id2 CHAR(10);
DEFINE a_id3 CHAR(60);
DEFINE a_id4 SMALLINT;
FOREACH
SELECT id, id2,id3,id4
INTO a_id, a_id2, a_id3, a_id4
FROM table
RETURN a_id, a_id2, a_id3, a_id4 WITH RESUME;
END FOREACH;
END PROCEDURE;
result:
set of records of [(exprssion),(exprssion),(exprssion),(exprssion)]
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (EJB-338) Query and @Column arround getter
by Cédric Chantepie (JIRA)
Query and @Column arround getter
--------------------------------
Key: EJB-338
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-338
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.3.1.GA
Environment: BEA JRockit(R) (build R26.4.0-63-63688-1.5.0_06-20060626-2259-linux-ia32, )
Reporter: Cédric Chantepie
When binding property with @Column annotation arround corresponding getter query "cannot resolve property", whereas all other persistence features (EntityManager.{persist,find,...}) properly supports it.
Just moving annotation to the private field fix this issue, but in some case you really want to mapped property from its getter and not from private (protected) field.
Annotation binding (causing issue) :
[...] class ProcessStateEntity {
[...]
@Column(name="col")
public Calendar getOccured() { ... }
[...]
}
Query exception :
org.hibernate.QueryException: could not resolve property: occured of: xxx.ProcessStateEntity [SELECT s.occured FROM xxx.Pr
ocessStateEntity s]
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyExcept
ion(AbstractPropertyMapping.java:44)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(Abstrac
tPropertyMapping.java:38)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(Abstrac
tEntityPersister.java:1358)
at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElemen
tType.java:279)
at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:386)
at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:566)
at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:241)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:188)
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (HSEARCH-158) QueryLoader, 'load' fails to load Objects that 'get' can load
by Jason Eacott (JIRA)
QueryLoader, 'load' fails to load Objects that 'get' can load
-------------------------------------------------------------
Key: HSEARCH-158
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-158
Project: Hibernate Search
Issue Type: Bug
Environment: mysql 5.0.27 (sorry), linux, windows, hibernate 3.2.5ga
Reporter: Jason Eacott
I noticed some odd results so I set up a test:
from my test (using spring)
for the same id:
this works - 1 result as expected.
SELECT * FROM contents where id='..';
this fails:
return (FeedItem) getHibernateTemplate().load(FeedItem.class, id);
this works:
return (FeedItem) getHibernateTemplate().get(FeedItem.class, id);
why should this forum care?
because in search.engine.QueryLoader this code fails to load data that clearly exists. I stepped through it and its perfect until the load clause:
---------------
//mandatory to keep the same ordering
List result = new ArrayList(entityInfos.length);
for (EntityInfo entityInfo : entityInfos) {
Object element = session.load( entityInfo.clazz, entityInfo.id );
if ( Hibernate.isInitialized( element ) ) {
//all existing elements should have been loaded by the query,
//the other ones are missing ones
result.add( element );
}
}
---------------
is this a hibernate bug? and/or should hibernatesearch use session.get instead to work around the problem?
--
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
18 years, 1 month
[Hibernate-JIRA] Commented: (HHH-1283) ScrollableResults JoinFetch don't set child collection correctly after the second parent object
by Gonzalo Bermúdez (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1283?page=c... ]
Gonzalo Bermúdez commented on HHH-1283:
---------------------------------------
We had been dealing with this bug for some time now, and found that skipping an early exit on org.hibernate.engine.loading.CollectionLoadContext.getLoadingCollection(CollectionPersister, Serializable) solved this problem.
We removed the following snippet:
if ( collection.wasInitialized() ) {
log.trace( "collection already initialized; ignoring" );
return null; // ignore this row of results! Note the early exit
}
else {
// initialize this collection
log.trace( "collection not yet initialized; initializing" );
}
Also, we had no noticeable performance drawbacks, nor any other problem. Is there any aspect we might be missing by patching Hibernate this way? Is this a valid solution?
> ScrollableResults JoinFetch don't set child collection correctly after the second parent object
> -----------------------------------------------------------------------------------------------
>
> Key: HHH-1283
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1283
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1
> Environment: Hibernate 3.1
> Oracle10gR2
> Oracle JDBC Driver 10.2.0.1.0
> Sun JDK 1.5.0_06
> Spring 1.2.6
> Reporter: Masahiro Hirashima
> Attachments: ScrollableCollectionFetchingTest.java, ScrollableResults.zip
>
>
> ScrollableResults JoinFetch set child collection correctly at first parent object.
> but after the second parent object, It set only the first element of a child collection.
> I made the following tables.
> CREATE TABLE owners (
> id NUMBER(36, 0) NOT NULL PRIMARY KEY,
> first_name VARCHAR(30),
> last_name VARCHAR(30),
> address VARCHAR(255),
> city VARCHAR(80),
> telephone VARCHAR(20),
> version NUMBER(36, 0) DEFAULT 0
> );
> CREATE TABLE types (
> id NUMBER(36, 0) NOT NULL PRIMARY KEY,
> name VARCHAR(80),
> version NUMBER(36, 0) DEFAULT 0
> );
> CREATE TABLE pets (
> id NUMBER(36, 0) NOT NULL PRIMARY KEY,
> name VARCHAR(30),
> birth_date DATE,
> type_id NUMBER(36, 0),
> owner_id NUMBER(36, 0),
> version NUMBER(36, 0) DEFAULT 0
> );
> and inserted the following data.
> INSERT INTO owners VALUES (1, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749', 0);
> INSERT INTO owners VALUES (2, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763', 0);
> INSERT INTO pets VALUES (1, 'Leo', '2000-09-07', 1, 1, 0);
> INSERT INTO pets VALUES (2, 'Basil', '2002-08-06', 2, 1, 0);
> INSERT INTO pets VALUES (3, 'Rosy', '2001-04-17', 3, 2, 0);
> INSERT INTO pets VALUES (4, 'Jewel', '2000-03-07', 4, 2, 0);
> INSERT INTO pets VALUES (5, 'Iggy', '2000-11-30', 5, 2, 0);
> INSERT INTO types VALUES (1, 'cat', 0);
> INSERT INTO types VALUES (2, 'dog', 0);
> INSERT INTO types VALUES (3, 'lizard', 0);
> INSERT INTO types VALUES (4, 'snake', 0);
> INSERT INTO types VALUES (5, 'bird', 0);
> and I execute following code.
> String hqlJoinFetchTest =
> "from Owner owner " +
> "left outer join fetch owner.pets as pets " +
> "left outer join fetch pets.type " +
> "order by owner.firstName, owner.lastName";
> Query query = session.createQuery(hqlJoinFetchTest);
> ScrollableResults cursor = query.scroll();
> while ( cursor.next() ) {
> Owner owner = (Owner)cursor.get(0);
> System.out.println(owner);
> }
> result of this code is following.
> petclinic.domain.Owner@15d616e[id=1,version=0,firstName=Betty,lastName=Davis,
> petclinic.domain.Pet@136d9d8[id=2,version=0,name=Basil,birthDate=2002-08-06,
> petclinic.domain.PetType@1be2893[id=2,version=0,name=dog]
> petclinic.domain.Pet@14a75bb[id=1,version=0,name=Leo,birthDate=2000-09-07,
> petclinic.domain.PetType@17779e3[id=1,version=0,name=cat]
> petclinic.domain.Owner@e3570c[id=2,version=0,firstName=Eduardo,lastName=Rodriquez
> petclinic.domain.Pet@167e3a5[id=4,version=0,name=Jewel,birthDate=2000-03-07,
> petclinic.domain.PetType@1926e90[id=4,version=0,name=snake]
> First owner object set collection collectly.
> but second owner object don't set second pet object(id=5) and third pet object(id=6).
--
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
18 years, 1 month