[Hibernate-JIRA] Created: (HHH-2711) PropertyAccessException with backref and <composite-map-key/>
by Steve Ebersole (JIRA)
PropertyAccessException with backref and <composite-map-key/>
-------------------------------------------------------------
Key: HHH-2711
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2711
Project: Hibernate3
Issue Type: Bug
Components: core
Reporter: Steve Ebersole
Assignee: Steve Ebersole
Priority: Minor
Fix For: 3.2.5, 3.3
Background ~~~~~~~~~~~
Whenever you map a one-to-many association unidirectionally from the many side, with the collection-key (FK) being defined as not-null, Hibernate creates a special property (PropertyAccessor) on the related entity which is used to determine the FK value.
~~~~~~~~~~~~~~~~~~~~
Currently, this causes problems in a few scenarios if that collection is a map and a <composite-map-key/> is used instead of a simple <map-key/>.
The trivial workaround is to specify that the map keys be nullable.
The fix is to have Hibernate either:
1) not attempt to access component sub-values from when the component instance == BrackrefPropertyAccessor.UNKNOWN;
2) have BrackrefPropertyAccessor be more aggressive in terms of trying to resolve the <composite-map-key/> in the first place.
#1 is definitely the way to go in terms of performance. But it might mean needing to do that check in a few different places...
--
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, 4 months
[Hibernate-JIRA] Commented: (HHH-1015) Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
by David Balažic (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1015?page=c... ]
David Balažic commented on HHH-1015:
------------------------------------
We have almost an identical situation as the reporter.
Is there at least a workaround ?
> Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
> -----------------------------------------------------------------------------------------
>
> Key: HHH-1015
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1015
> Project: Hibernate3
> Issue Type: New Feature
> Components: core
> Affects Versions: 3.1 beta 2
> Environment: Hibernate versions 3.1 beta 3 and 3.0.5
> Reporter: Steven Grimm
> Priority: Minor
>
> I have the following mappings describing a hierarchy of events and a class that the events refer to:
> <hibernate-mapping package="com.xyz">
> <class name="Event" table="event" discriminator-value="-1">
> <id name="Id" type="long" column="event_id"/>
> <discriminator column="event_type_id" type="integer" />
> <subclass name="EventPayer" discriminator-value="-3">
> <join table="event_payer">
> <key column="event_id" />
> <many-to-one name="payer" column="payer_id" class="Payer" />
> </join>
> <subclass name="EventPayerCreated" discriminator-value="1" />
> </subclass>
> </class>
> <class name="Payer" table="payer">
> <id name="payerId" column="payer_id" type="java.lang.Long"/>
> <set name="eventPayers" inverse="true" cascade="save-update">
> <key column="payer_id"/>
> <one-to-many class="EventPayer"/>
> </set>
> </class>
> </hibernate-mapping>
> When I fetch the Payer.eventPayers collection, Hibernate generates this SQL:
> select eventpayer0_.payer_id as payer7_1_,
> eventpayer0_.event_id as event1_1_,
> eventpayer0_.event_id as event1_5_0_,
> eventpayer0_1_.payer_id as payer2_6_0_,
> eventpayer0_.event_type_id as event2_5_0_
> from event eventpayer0_
> inner join event_payer eventpayer0_1_
> on eventpayer0_.event_id=eventpayer0_1_.event_id
> where eventpayer0_.payer_id=?
> The problem is that there is no event.payer_id column; payer_id is in the child table, not the parent. It appears that specifying a discriminated subclass in <one-to-many> is the same as specifying the superclass, or that Hibernate is ignoring the subclass's <join> element. As far as I can tell, this leaves no way to resolve bidirectional associations where one end of the association is in a discriminated subclass, which seems like a perfectly reasonable thing to want to do.
> I also tried changing <key column="payer_id"/> to <key property-ref="payer"/> in the Payer class's <set> element, but got similar behavior in the form of a "property not found" error: Hibernate is either looking in the superclass's properties rather than the subclass's or is ignoring the list of properties in the <join> element.
--
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, 5 months
[Hibernate-JIRA] Commented: (HHH-1685) DetachedCriteria doesn't create alias on subcriteria
by Rastislav Siekel (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1685?page=c... ]
Rastislav Siekel commented on HHH-1685:
---------------------------------------
I have the same problem. Patch from Description not help me. Aliases in subquery (4-deep IN clause) is always "this0__".
> DetachedCriteria doesn't create alias on subcriteria
> ----------------------------------------------------
>
> Key: HHH-1685
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1685
> Project: Hibernate3
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.1.3
> Reporter: John
> Attachments: hhh1685-example.txt
>
>
> DetachedCriteria has two createCriteria methods:
> public DetachedCriteria createCriteria(String associationPath) throws HibernateException
> public DetachedCriteria createCriteria(String associationPath, String alias) throws HibernateException
> However, the code for both was identical - they called the inner criteria's createCriteria(String) method. The version with the alias did not call the inner's version with the alias. The following patch snipped shows the change:
> public DetachedCriteria createCriteria(String associationPath, String alias)
> throws HibernateException {
> - return new DetachedCriteria( impl, criteria.createCriteria(associationPath) );
> + return new DetachedCriteria( impl, criteria.createCriteria(associationPath, alias) );
> }
> This bug was discovered while trying to link a 2-deep subquery to its parent via aliases. (Surfacing this issue might only be possible with the patch HHH-952 in place - I'm not sure. Seems like a bug regardless, as it definitely fixed my alias reference issue.) I'll get an example posted shortly.
--
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, 5 months
[Hibernate-JIRA] Created: (HBX-915) CLONE -Hibernate ant task does not work in a multi-project Maven 2 build if other mojos use javax.xml.transform
by Brill Pappin (JIRA)
CLONE -Hibernate ant task does not work in a multi-project Maven 2 build if other mojos use javax.xml.transform
---------------------------------------------------------------------------------------------------------------
Key: HBX-915
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-915
Project: Hibernate Tools
Type: Bug
Components: ant
Versions: 3.1beta4
Environment: Hibernate 3.1, database is Oracle (but not relevant to this)
Reporter: Brill Pappin
Fix For: 3.2beta7
I have a reasonably complex maven 2 build with multiple projects. More than one of the projects uses the hbm2java task and at least one of the projects uses the Codehaus xslt-maven-plugin. When running the project that uses both hbm2java and XSLT, it works fine. But running the master build throws the following error.
org.apache.maven.lifecycle.LifecycleExecutionException: Error executing ant tasks
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
[snip]
Caused by: java.lang.IllegalStateException: 3.1.0.beta4 found when setting version
at org.hibernate.tool.hbm2x.TemplateHelper.putInContext(TemplateHelper.java:223)
[snip]
I can't really explain where this error is coming from. I looked at the source for putInContext and it is using the Plexus options class and failing because the value of "version" is already in the options.
I assumed from this it was a problem with the xstl-maven-plugin from Codehaus also using some Plexus libraries, but I refactored the mojo so it was ONLY using javax.xml.transform and the problem remained.
I then changed my slimmed down mojo to force use of Saxon instead of the default JAXP implementation (Xalan?).
.. and it worked fine!
So this is definitely a problem with the instantiation of the default XSLT functionality in JDK1.4, although how that can possibly affect the build in this way is beyond me.
You might consider this a Maven bug but it's very strange that it doesn't happen for any old mojo combination. I also think it is probably much easier to fix in Hibernate tools than in Maven.
I'd suggest a couple of possible fixes/improvements:
- Make "version" key more specific, eg. hibernate.tools.version to avoid possible clash with other Plexus clients in the same JVM
- Don't throw an exception on any existing value being set as it is now but compare the value in the options to the new value and only throw an exception if they differ
I can't think of a way to track down the underlying cause of this issue. It's a very odd one.
Attached is a simple three project build to reproduce the problem. Just run 'mvn clean package' on the parent project to reproduce.
--
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, 5 months
[Hibernate-JIRA] Created: (HBX-953) java.lang.UnsupportedOperationException: accept on org.hibernate.mapping.DependantValue
by Ray DeCampo (JIRA)
java.lang.UnsupportedOperationException: accept on org.hibernate.mapping.DependantValue
---------------------------------------------------------------------------------------
Key: HBX-953
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-953
Project: Hibernate Tools
Issue Type: Bug
Components: hbm2doc
Affects Versions: 3.2beta9
Environment: Hibernate 3.2.3, tested with 3.2.0 and 3.2.4.sp1
Reporter: Ray DeCampo
Priority: Minor
When running hbm2doc via ANT and using the GraphViz dot.executable property, I get the following error:
[hibernatetool] Jun 22, 2007 2:59:22 PM freemarker.log.JDK14LoggerFactory$JDK14Logger error
[hibernatetool] SEVERE:
[hibernatetool]
[hibernatetool] Method public java.lang.String org.hibernate.tool.hbm2x.Cfg2HbmTool.getHibernateTypeName(org.hibernate.mapping.Property) threw an exce
ption when invoked on org.hibernate.tool.hbm2x.Cfg2HbmTool@7f5580
[hibernatetool] The problematic instruction:
[hibernatetool] ----------
[hibernatetool] ==> if c2h.getHibernateTypeName(property)?exists [on line 62, column 6 in dot/entitygraph.dot.ftl]
[hibernatetool] in user-directive propertyEdges [on line 32, column 3 in dot/entitygraph.dot.ftl]
[hibernatetool] ----------
[hibernatetool]
[hibernatetool] Java backtrace for programmers:
[hibernatetool] ----------
[hibernatetool] freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.Cfg2HbmTool.getHibernateTypeName(o
rg.hibernate.mapping.Property) threw an exception when invoked on org.hibernate.tool.hbm2x.Cfg2HbmTool@7f5580
[hibernatetool] at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
[hibernatetool] at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
[hibernatetool] at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
[hibernatetool] at freemarker.core.BuiltIn$existsBI._getAsTemplateModel(BuiltIn.java:635)
[hibernatetool] at freemarker.core.BuiltIn$existsBI.isTrue(BuiltIn.java:646)
[hibernatetool] at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:351)
[hibernatetool] at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.Macro$Context.runMacro(Macro.java:164)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:537)
[hibernatetool] at freemarker.core.UnifiedCall.accept(UnifiedCall.java:128)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:351)
[hibernatetool] at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.Environment.process(Environment.java:176)
[hibernatetool] at freemarker.template.Template.process(Template.java:231)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:247)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:97)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter$1.process(GenericExporter.java:30)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:126)
[hibernatetool] at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
[hibernatetool] at org.hibernate.tool.hbm2x.DocExporter.generateDot(DocExporter.java:182)
[hibernatetool] at org.hibernate.tool.hbm2x.DocExporter.doStart(DocExporter.java:151)
[hibernatetool] at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
[hibernatetool] at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:183)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[hibernatetool] at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
[hibernatetool] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[hibernatetool] at java.lang.reflect.Method.invoke(Method.java:597)
[hibernatetool] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:348)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:357)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[hibernatetool] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
[hibernatetool] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
[hibernatetool] at org.apache.tools.ant.Main.runBuild(Main.java:698)
[hibernatetool] at org.apache.tools.ant.Main.startAnt(Main.java:199)
[hibernatetool] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[hibernatetool] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
[hibernatetool] Caused by: java.lang.UnsupportedOperationException: accept on org.hibernate.mapping.DependantValue([org.hibernate.mapping.Column(serve
_id)])
[hibernatetool] at org.hibernate.tool.hbm2x.visitor.DefaultValueVisitor.handle(DefaultValueVisitor.java:40)
[hibernatetool] at org.hibernate.tool.hbm2x.visitor.DefaultValueVisitor.accept(DefaultValueVisitor.java:97)
[hibernatetool] at org.hibernate.mapping.DependantValue.accept(DependantValue.java:31)
[hibernatetool] at org.hibernate.tool.hbm2x.Cfg2HbmTool.getHibernateTypeName(Cfg2HbmTool.java:380)
[hibernatetool] at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
[hibernatetool] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[hibernatetool] at java.lang.reflect.Method.invoke(Method.java:597)
[hibernatetool] at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:583)
[hibernatetool] at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
[hibernatetool] ... 56 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(o
rg.hibernate.mapping.Property) threw an exception when invoked on org.hibernate.tool.hbm2x.Cfg2HbmTool@7f5580
[hibernatetool] java.lang.UnsupportedOperationException: accept on org.hibernate.mapping.DependantValue([org.hibernate.mapping.Column(serve_id)])
--
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, 5 months