[Hibernate-JIRA] Created: (HHH-2353) ClassCastException thrown in org.hibernate.hql.ast.HqlSqlWalker.resolve
by James Andrews (JIRA)
ClassCastException thrown in org.hibernate.hql.ast.HqlSqlWalker.resolve
-----------------------------------------------------------------------
Key: HHH-2353
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2353
Project: Hibernate3
Type: Bug
Versions: 3.2.1, 3.2.0.cr4
Environment: Currently Hibernate 3.2.1, MySQL 5.0.26, Tomcat 5.5.20, Java 1.5 patch 10
Reporter: James Andrews
Above error thrown when attempting to force a left join fetch in hql on a many-to-many mapping:
Using 3 tables
accountgroup
id INTEGER PRIMARY
...
accountline
id INTEGER PRIMARY
...
accountgroupmapping
id INTEGER PRIMARY
groupId INTEGER
lineId INTEGER
...
Set mapping in hbm:
<set name="lines" table="budget.grouplinemap" fetch="join" lazy="false">
<key column="groupId" not-null="true"></key>
<many-to-many class="intranet.budget.AccountLine"
column="lineId" fetch="join" lazy="false">
</many-to-many>
</set>
HQL query executed:
select group from AccountGroup group left join fetch group.lines
Result:
java.lang.ClassCastException: org.hibernate.hql.ast.tree.SqlNode
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:722)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1105)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRefLhs(HqlSqlBaseWalker.java:4920)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1066)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3198)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3067)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
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)
The above works fine if I remove the left join fetch, or if I make the relationship one-to-many, but when I create a many-to-many relationship the error above occurs.
But since the above is being encoded to an AJAX frontend, and the lines fields are referenced immediately, removing the left join fetch results in N+1 selects despite the fetch="join" and lazy="false" in the .hbm descriptor.
--
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, 1 month
[Hibernate-JIRA] Created: (HHH-2016) Oracle9Dialect registers last_day() function as "lastday"
by Carl Lindberg (JIRA)
Oracle9Dialect registers last_day() function as "lastday"
---------------------------------------------------------
Key: HHH-2016
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2016
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.0 alpha, 3.0 beta 1, 3.0 beta 2, 3.0 beta 3, 3.0 beta 4, 3.0 rc 1, 3.0 final, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1 beta 1, 3.1 beta 2, 3.1 rc 1, 3.1 rc2, 3.1 rc3, 3.1, 3.1.1, 3.1.2, 3.2.0.alpha1, 3.2.0.alpha2, 3.1.3, 3.2.0 cr1, 3.2.0.cr2, 3.2.0.cr3
Environment: Hibernate 2.x, 3.x with an Oracle database
Reporter: Carl Lindberg
Priority: Minor
Attachments: Oracle9DialectPatch.diff, Oracle9DialectPatchOption2.diff
Oracle9Dialect.java registers a "lastday" function, however the actual Oracle function is last_day() (with the underscore). This results in a SQL error if the function is used in HQL (and obviously, HQL will not accept use of "last_day").
The patch is basically:
- registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
or, if support for the incorrect "lastday" usage should still be supported:
- registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
+ registerFunction( "lastday", new StandardSQLFunction("last_day", Hibernate.DATE) );
Both patch options are 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, 1 month
[Hibernate-JIRA] Created: (HBX-755) incorrect genreated code for many-to-many relationship
by azamjalali (JIRA)
incorrect genreated code for many-to-many relationship
-------------------------------------------------------
Key: HBX-755
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-755
Project: Hibernate Tools
Type: Bug
Components: ant
Versions: 3.2beta7
Reporter: azamjalali
The following code is generated for Table rolea and roleb( these tables have many-to-many relation). Both of entities use ManytoMany annotation without jointable annotation.
/////////////////////////////////////////////////////////////////////
package trce.impr.subsystem.entity;
// Generated Sep 17, 2006 1:04:06 AM by Hibernate Tools 3.2.0.beta7
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
/**
* RoleB generated by hbm2java
*/
@Entity
@Table(name="roleb"
,catalog="registration"
, uniqueConstraints = { }
)
public class RoleB implements java.io.Serializable {
// Fields
private int rolebId;
private Set<RoleA> roleas = new HashSet<RoleA>(0);
// Constructors
/** default constructor */
public RoleB() {
}
/** minimal constructor */
public RoleB(int rolebId) {
this.rolebId = rolebId;
}
/** full constructor */
public RoleB(int rolebId, Set<RoleA> roleas) {
this.rolebId = rolebId;
this.roleas = roleas;
}
// Property accessors
@Id
@Column(name="roleb_id", unique=true, nullable=false, insertable=true, updatable=true)
public int getRolebId() {
return this.rolebId;
}
public void setRolebId(int rolebId) {
this.rolebId = rolebId;
}
@ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY, mappedBy="rolebs")
public Set<RoleA> getRoleas() {
return this.roleas;
}
public void setRoleas(Set<RoleA> roleas) {
this.roleas = roleas;
}
}
////////////////////////////////////////////////////////////////////////////////////
package trce.impr.subsystem.entity;
// Generated Sep 17, 2006 1:04:06 AM by Hibernate Tools 3.2.0.beta7
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
/**
* RoleA generated by hbm2java
*/
@Entity
@Table(name="rolea"
,catalog="registration"
, uniqueConstraints = { }
)
public class RoleA implements java.io.Serializable {
// Fields
private int roleaId;
private Set<RoleB> rolebs = new HashSet<RoleB>(0);
// Constructors
/** default constructor */
public RoleA() {
}
/** minimal constructor */
public RoleA(int roleaId) {
this.roleaId = roleaId;
}
/** full constructor */
public RoleA(int roleaId, Set<RoleB> rolebs) {
this.roleaId = roleaId;
this.rolebs = rolebs;
}
// Property accessors
@Id
@Column(name="rolea_id", unique=true, nullable=false, insertable=true, updatable=true)
public int getRoleaId() {
return this.roleaId;
}
y
public void setRoleaId(int roleaId) {
this.roleaId = roleaId;
}
@ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY, mappedBy="roleas")
public Set<RoleB> getRolebs() {
return this.rolebs;
}
public void setRolebs(Set<RoleB> rolebs) {
this.rolebs = rolebs;
}
}
//////////////////////////////////////////////////////////////////////
--
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, 1 month
[Hibernate-JIRA] Created: (HBX-774) ClassCastException by create/open/execute a *.hql file
by Damir Isanbirdin (JIRA)
ClassCastException by create/open/execute a *.hql file
------------------------------------------------------
Key: HBX-774
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-774
Project: Hibernate Tools
Type: Bug
Components: visualizations, eclipse, consoleconfiguration
Versions: 3.1.beta5, 3.1beta5a, 3.2beta6, 3.2beta7, 3.2beta8
Environment: 3.1.0 beta 5. Eclipse-plugin, DB: HSQLDB
Reporter: Damir Isanbirdin
Priority: Blocker
!ENTRY org.eclipse.ui 4 4 2006-10-04 04:17:14.265
!MESSAGE Unhandled event loop exception
!ENTRY org.eclipse.ui 4 0 2006-10-04 04:17:14.265
!MESSAGE Failed to execute runnable (java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput)
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput)
....
!ENTRY org.eclipse.ui 4 4 2006-10-04 04:17:16.921
!MESSAGE Save Failed
!STACK 0
java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput
at org.hibernate.eclipse.hqleditor.HQLEditor.doSave(HQLEditor.java:430)
at org.eclipse.ui.internal.SaveableHelper$1.run(SaveableHelper.java:95)
at org.eclipse.ui.internal.SaveableHelper$2.run(SaveableHelper.java:116)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:346)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:291)
!ENTRY org.eclipse.ui 4 4 2006-10-04 04:17:17.296
!MESSAGE Unhandled event loop exception
!ENTRY org.eclipse.ui 4 0 2006-10-04 04:17:17.296
!MESSAGE Failed to execute runnable (java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput)
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput)
at org.eclipse.swt.SWT.error(SWT.java:2942)
at org.eclipse.swt.SWT.error(SWT.java:2865)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:126)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3102)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2761)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:809)
... 51 more
!ENTRY org.hibernate.eclipse.console 4 150 2006-10-04 04:17:29.687
!MESSAGE Exception while executing HQL Query
!SUBENTRY 1 org.hibernate.eclipse.console 4 150 2006-10-04 04:17:29.703
!MESSAGE org.hibernate.QueryException: unexpected char: ';' [select s from mapping.ScaleData s, mapping.ScalesMappingData sm, mapping.AgencyRatingData ar, mapping.AgencyData a
where s.scaleid=sm.scale.scaleid
and sm.agencyrating.ratingid=ar.ratingid
and ar.agency.agencyid=a.agencyid
and a.agencyname=: param1
and ar.rating= :param2;]
!STACK 0
org.hibernate.QueryException: unexpected char: ';' [select s from mapping.ScaleData s, mapping.ScalesMappingData sm, mapping.AgencyRatingData ar, mapping.AgencyData a
where s.scaleid=sm.scale.scaleid
and sm.agencyrating.ratingid=ar.ratingid
and ar.agency.agencyid=a.agencyid
and a.agencyname=: param1
and ar.rating= :param2;]
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:110)
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:71)
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:1586)
at org.hibernate.console.HQLQueryPage.setSession(HQLQueryPage.java:77)
at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:292)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35)
at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:287)
at org.hibernate.eclipse.console.actions.ExecuteHQLAction.execute(ExecuteHQLAction.java:134)
at org.hibernate.eclipse.console.actions.ExecuteHQLAction$2.run(ExecuteHQLAction.java:104)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:996)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538)
...
!ENTRY org.eclipse.ui 4 4 2006-10-04 04:17:36.171
!MESSAGE Save Failed
!ENTRY org.eclipse.ui 2 0 2006-10-04 04:17:36.171
!MESSAGE Save Failed
!STACK 0
java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput
at org.hibernate.eclipse.hqleditor.HQLEditor.doSave(HQLEditor.java:430)
at org.eclipse.ui.internal.SaveableHelper$1.run(SaveableHelper.java:95)
at org.eclipse.ui.internal.SaveableHelper$2.run(SaveableHelper.java:116)
...
!ENTRY org.eclipse.ui 4 4 2006-10-04 04:17:42.484
!MESSAGE Save Failed
!ENTRY org.eclipse.ui 2 0 2006-10-04 04:17:42.500
!MESSAGE Save Failed
!STACK 0
java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput
at org.hibernate.eclipse.hqleditor.HQLEditor.doSave(HQLEditor.java:430)
at org.eclipse.ui.internal.SaveableHelper$1.run(SaveableHelper.java:95)
at org.eclipse.ui.internal.SaveableHelper$2.run(SaveableHelper.java:116)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:346)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:291)
at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:624)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:621)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2134)
...
!ENTRY org.eclipse.ui.workbench 4 2 2006-10-04 04:17:48.78
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput
at org.hibernate.eclipse.hqleditor.HQLEditor.getConsoleConfiguration(HQLEditor.java:438)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView.updateText(DynamicSQLPreviewView.java:115)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView.setCurrentEditor(DynamicSQLPreviewView.java:108)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView.hookIntoEditor(DynamicSQLPreviewView.java:92)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView.access$2(DynamicSQLPreviewView.java:85)
at org.hibernate.eclipse.console.views.DynamicSQLPreviewView$1.partBroughtToTop(DynamicSQLPreviewView.java:70)
at org.eclipse.ui.internal.PartListenerList2$2.run(PartListenerList2.java:83)
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
at org.eclipse.core.runtime.Platform.run(Platform.java:783)
at org.eclipse.ui.internal.PartListenerList2.fireEvent(PartListenerList2.java:54)
...
--
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, 1 month
[Hibernate-JIRA] Created: (ANN-438) Merging annotations and XML sometimes causes an XML parser error
by James Telfer (JIRA)
Merging annotations and XML sometimes causes an XML parser error
----------------------------------------------------------------
Key: ANN-438
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-438
Project: Hibernate Annotations
Type: Bug
Versions: 3.2.0.cr1
Environment: Hibernate 3.2 CR2, SQL Server 2005
Reporter: James Telfer
I created a class and annotated it with EJB 3 annotations, then created an XML descriptor to store my named queries. The XML I used is excerpted below. I then added the mapping file to my cfg.xml as a <mapping resource=""/%gt; element. When Hibernate was configured, it threw the parser exception included below also.
The same error occurred when configuring my application within Tomcat (via Spring). To narrow down the problemI created a very simple class to configure Hibernate and ran that in Eclipse. This worked. The line used to configure Hibernate was: <code>new AnnotationConfiguration().configure(new File("hibernate.cfg.xml")).buildSessionFactory();</code>.
Eclipse is running on Windows using the JDK 1.5.07 Server VM with parallel GC and the Eclipse runner used the JDK server VM with standard GC. Tomcat was using the JRE 1.5.07 client VM. I changed the VM used by Tomcat and it succeeded. Hibernate Tools still fails to read the configuration file.
If any further information is required, I'd be happy to provide it. There is a forum thread (http://forum.hibernate.org/viewtopic.php?p=2310540&sid=f14052739a96c418c3...) that describes a similar problem, but the user's fix is not feasible in this scenario.
<pre>
org.hibernate.MappingException: Could not read mappings from resource: au/com/crowncontent/precis/entries/dao/mappings.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:523)
at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:425)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1479)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1458)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1432)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1386)
at org.hibernate.console.ConsoleConfiguration.loadConfigurationXML(ConsoleConfiguration.java:225)
at org.hibernate.console.ConsoleConfiguration.access$0(ConsoleConfiguration.java:172)
at org.hibernate.console.ConsoleConfiguration$1.execute(ConsoleConfiguration.java:148)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:129)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:109)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:54)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:63)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
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.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:571)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:520)
... 39 more
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'entity-mappings'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1944)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:567)
... 40 more
</pre>
ORM XML:
<pre>
<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
version="1.0">
<package>au.com.blah.entries</package>
<entity class="Entry" metadata-complete="false">
<named-query name="entries.Entry.searchEntries">
<query>
select ...
etc etc
</query>
<hint name="org.hibernate.readOnly" value="true"/>
<hint name="org.hibernate.fetchSize" value="50"/>
</named-query>
</entity>
</entity-mappings>
</pre>
--
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, 1 month
[Hibernate-JIRA] Created: (HHH-2000) CLONE -merge() with one-to-one throws ClassCastException
by Marco Rothe (JIRA)
CLONE -merge() with one-to-one throws ClassCastException
--------------------------------------------------------
Key: HHH-2000
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2000
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1 beta 2
Reporter: Marco Rothe
Hibernate tries to bind a persistent object to a long variable in a SQL statement during a call to merge() on an object with a one-to-one relation.
I originally posted about this problem here: http://forum.hibernate.org/viewtopic.php?t=948272&highlight=
I have created and attached a junit test to reproduce the problem. When running against 3.0 or 3.1beta2 the ClassCastException is thrown all the way out, as shown in the forum post. The latest code from cvs catches the exception and logs it. org.hibernate.type.NullableType.java rev 1.10 is where the exception is caught. It seems like it should be logged and then re-thrown, but it's not. The debug log from the start of the merge() call to where it logs that it failed to bind the value is:
[junit] 11:12:32,461 DEBUG SessionImpl:271 - opened session at timestamp: 11283595524
[junit] 11:12:32,461 DEBUG JDBCTransaction:54 - begin
[junit] 11:12:32,461 DEBUG ConnectionManager:309 - opening JDBC connection
[junit] 11:12:32,461 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
[junit] 11:12:32,461 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
[junit] 11:12:32,461 DEBUG JDBCTransaction:59 - current autocommit status: false
[junit] 11:12:32,461 DEBUG JDBCContext:207 - before transaction completion
[junit] 11:12:32,477 DEBUG IdentifierValue:207 - id unsaved-value: null
[junit] 11:12:32,477 DEBUG AbstractSaveEventListener:470 - detached instance of: org.hibernate.test.onetoone.merge.Person
[junit] 11:12:32,477 DEBUG DefaultMergeEventListener:185 - merging detached instance
[junit] 11:12:32,477 DEBUG DefaultLoadEventListener:153 - loading entity: [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,477 DEBUG DefaultLoadEventListener:304 - attempting to resolve: [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,477 DEBUG DefaultLoadEventListener:340 - object not resolved in any cache: [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,477 DEBUG ConnectionManager:389 - running Session.finalize()
[junit] 11:12:32,477 DEBUG AbstractEntityPersister:2722 - Fetching entity: [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,493 DEBUG Loader:1774 - loading entity: [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,493 DEBUG AbstractBatcher:309 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[junit] 11:12:32,493 DEBUG SQL:344 -
[junit] select
[junit] person0_.person_id as person1_0_0_
[junit] from
[junit] person person0_
[junit] where
[junit] person0_.person_id=?
[junit] 11:12:32,493 DEBUG AbstractBatcher:413 - preparing statement
[junit] 11:12:32,493 DEBUG AbstractBatcher:325 - about to open ResultSet (open ResultSets: 0, globally: 0)
[junit] 11:12:32,508 DEBUG Loader:682 - processing result set
[junit] 11:12:32,508 DEBUG Loader:687 - result set row: 0
[junit] 11:12:32,508 DEBUG Loader:1164 - result row: EntityKey[org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,508 DEBUG Loader:1347 - Initializing object from ResultSet: [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,508 DEBUG AbstractEntityPersister:1859 - Hydrating entity: [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,508 DEBUG Loader:709 - done processing result set (1 rows)
[junit] 11:12:32,524 DEBUG AbstractBatcher:332 - about to close ResultSet (open ResultSets: 1, globally: 1)
[junit] 11:12:32,524 DEBUG AbstractBatcher:317 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[junit] 11:12:32,524 DEBUG AbstractBatcher:459 - closing statement
[junit] 11:12:32,524 DEBUG Loader:839 - total objects hydrated: 1
[junit] 11:12:32,524 DEBUG TwoPhaseLoad:104 - resolving associations for [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,524 DEBUG Loader:1774 - loading entity: [org.hibernate.test.onetoone.merge.Address#1]
[junit] 11:12:32,539 DEBUG AbstractBatcher:309 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[junit] 11:12:32,539 DEBUG SQL:344 -
[junit] select
[junit] address0_.address_id as address1_1_0_,
[junit] address0_.person_id as person2_1_0_
[junit] from
[junit] address address0_
[junit] where
[junit] address0_.person_id=?
[junit] 11:12:32,555 DEBUG AbstractBatcher:413 - preparing statement
[junit] 11:12:32,555 DEBUG AbstractBatcher:325 - about to open ResultSet (open ResultSets: 0, globally: 0)
[junit] 11:12:32,555 DEBUG Loader:682 - processing result set
[junit] 11:12:32,571 DEBUG Loader:687 - result set row: 0
[junit] 11:12:32,571 DEBUG Loader:1164 - result row: EntityKey[org.hibernate.test.onetoone.merge.Address#2]
[junit] 11:12:32,571 DEBUG Loader:1347 - Initializing object from ResultSet: [org.hibernate.test.onetoone.merge.Address#2]
[junit] 11:12:32,571 DEBUG AbstractEntityPersister:1859 - Hydrating entity: [org.hibernate.test.onetoone.merge.Address#2]
[junit] 11:12:32,571 DEBUG Loader:709 - done processing result set (1 rows)
[junit] 11:12:32,571 DEBUG AbstractBatcher:332 - about to close ResultSet (open ResultSets: 1, globally: 1)
[junit] 11:12:32,571 DEBUG AbstractBatcher:317 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[junit] 11:12:32,571 DEBUG AbstractBatcher:459 - closing statement
[junit] 11:12:32,586 DEBUG Loader:839 - total objects hydrated: 1
[junit] 11:12:32,586 DEBUG TwoPhaseLoad:104 - resolving associations for [org.hibernate.test.onetoone.merge.Address#2]
[junit] 11:12:32,586 DEBUG DefaultLoadEventListener:153 - loading entity: [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,586 DEBUG DefaultLoadEventListener:222 - entity found in session cache
[junit] 11:12:32,602 DEBUG TwoPhaseLoad:203 - done materializing entity [org.hibernate.test.onetoone.merge.Address#2]
[junit] 11:12:32,602 DEBUG Loader:1805 - done entity load
[junit] 11:12:32,602 DEBUG TwoPhaseLoad:203 - done materializing entity [org.hibernate.test.onetoone.merge.Person#1]
[junit] 11:12:32,602 DEBUG StatefulPersistenceContext:784 - initializing non-lazy collections
[junit] 11:12:32,602 DEBUG Loader:1805 - done entity load
[junit] 11:12:32,602 DEBUG Loader:1774 - loading entity: [org.hibernate.test.onetoone.merge.Address#org.hibernate.test.onetoone.merge.Person@153f67e]
[junit] 11:12:32,602 DEBUG AbstractBatcher:309 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[junit] 11:12:32,602 DEBUG SQL:344 -
[junit] select
[junit] address0_.address_id as address1_1_0_,
[junit] address0_.person_id as person2_1_0_
[junit] from
[junit] address address0_
[junit] where
[junit] address0_.person_id=?
[junit] 11:12:32,618 DEBUG AbstractBatcher:413 - preparing statement
[junit] 11:12:32,618 INFO LongType:89 - could not bind value 'org.hibernate.test.onetoone.merge.Person@153f67e' to parameter: 1
Running the test on HSQLDB with the latest from cvs hides the problem (logs it as INFO, but doesn't complain that nothing is bound to the variable), but if you run on PostgreSQL, for example, it complains (SQLException) that nothing is bound to the variable when the statement is executed ( org.postgresql.util.PSQLException: No value specified for parameter 1.):
[junit] 11:12:32,633 DEBUG AbstractBatcher:317 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[junit] 11:12:32,633 DEBUG AbstractBatcher:459 - closing statement
[junit] 11:12:32,649 DEBUG JDBCExceptionReporter:63 - could not load an entity: [org.hibernate.test.onetoone.merge.Address#org.hibernate.test.onetoone.merge.Person@153f67e] [select address0_.address_id as address1_1_0_, address0_.person_id as person2_1_0_ from address address0_ where address0_.person_id=?]
[junit] org.postgresql.util.PSQLException: No value specified for parameter 1.
[junit] at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:102)
[junit] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:166)
[junit] at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
[junit] at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330)
[junit] at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:240)
[junit] at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:137)
[junit] at org.hibernate.loader.Loader.getResultSet(Loader.java:1676)
[junit] at org.hibernate.loader.Loader.doQuery(Loader.java:662)
[junit] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
[junit] at org.hibernate.loader.Loader.loadEntity(Loader.java:1782)
[junit] at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
[junit] at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:85)
[junit] at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1522)
[junit] at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:365)
[junit] at org.hibernate.type.EntityType.resolve(EntityType.java:306)
[junit] at org.hibernate.type.EntityType.replace(EntityType.java:207)
[junit] at org.hibernate.type.TypeFactory.replace(TypeFactory.java:431)
[junit] at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:279)
[junit] at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:245)
[junit] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:102)
[junit] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
[junit] at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:609)
[junit] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:595)
[junit] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:599)
[junit] at org.hibernate.test.onetoone.merge.OneToOneTest.testOne(OneToOneTest.java:52)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:585)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at org.hibernate.test.TestCase.runTest(TestCase.java:140)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
[junit] 11:12:32,664 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 22023
[junit] 11:12:32,664 ERROR JDBCExceptionReporter:72 - No value specified for parameter 1.
[junit] 11:12:32,680 DEBUG SessionImpl:290 - closing session
[junit] 11:12:32,680 DEBUG ConnectionManager:330 - closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
[junit] 11:12:32,680 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
[junit] 11:12:32,680 INFO SessionFactoryImpl:865 - closing
[junit] 11:12:32,680 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:postgresql://localhost:5432/hibtest
[junit] 11:12:32,680 INFO SchemaExport:153 - Running hbm2ddl schema export
[junit] 11:12:32,696 DEBUG SchemaExport:171 - import file not found: /import.sql
[junit] 11:12:32,696 INFO SchemaExport:180 - exporting generated schema to database
[junit] 11:12:32,696 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
[junit] 11:12:32,696 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
[junit] 11:12:32,774 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:postgresql://localhost:5432/hibtest, Isolation Level: 2
[junit] 11:12:32,789 DEBUG SchemaExport:283 -
[junit] alter table address
[junit] drop constraint FKBB979BF4986F6BA3
[junit] 11:12:32,805 DEBUG SchemaExport:283 -
[junit] drop table address
[junit] 11:12:32,836 DEBUG SchemaExport:283 -
[junit] drop table person
[junit] 11:12:32,867 DEBUG SchemaExport:283 -
[junit] drop sequence hibernate_sequence
[junit] 11:12:32,883 INFO SchemaExport:200 - schema export complete
[junit] 11:12:32,883 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 5.233 sec
[junit] Test org.hibernate.test.onetoone.merge.OneToOneTest FAILED
--
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, 1 month