[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
16 years, 9 months
[Hibernate-JIRA] Commented: (HHH-951) setMaxResults causes "ORA-00918: column ambiguously defined" exception
by Rob Harrington (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-951?page=co... ]
Rob Harrington commented on HHH-951:
------------------------------------
I am seeing this in 3.2.5.ga. I am working on porting from 3.0.5, for which this was not an issue. For me, it's not a case sensitivity issue, or not qualifying the column with a table name or alias. Using the Criteria API, something like this:
Criteria crit = buildQuery(opt); // huge method left out for brevity
crit.setFirstResult(0);
crit.setMaxResults(25);
c = crit.list();
results in something like this for SQL:
SELECT *
FROM (SELECT this_.io_item_a_id AS io1_14_5_,
this_.creation_dt AS creation2_14_5_,
.
.
.
this_.package_main_fl AS package15_14_5_,
this_.insertion_order_id AS insertion16_14_5_, --dupe
this_.solomon_item_id AS solomon17_14_5_,
this_.parent_io_item_a_id AS parent18_14_5_,
this_.line_group_id AS line19_14_5_,
this_.io_item_state_cd AS io20_14_5_,
this_.insertion_order_id AS insertion16_14_5_, --dupe
this_.assignment_id AS assignment21_14_5_,
.
.
.
packageins9_.package_instance_id AS package1_84_4_,
packageins9_.bundle_cd AS bundle2_84_4_
FROM [removed for brevity]
WHERE [removed for brevity]
ORDER BY [removed for brevity]
)
WHERE ROWNUM <= 25
So as you can see 'this_.insertion_order_id' is included twice with the same alias. Obviously I've left out a LOT of detail and no Test Case. Not including that for now in the hope that I've described the issue well enough to get feedback on whether this is a known issue or indeed requires more description (test case) from me, which will take a while to put together.
> setMaxResults causes "ORA-00918: column ambiguously defined" exception
> -----------------------------------------------------------------------
>
> Key: HHH-951
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-951
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.1 beta 2
> Environment: hibernate3.0.5, hibernate3.1b2, Oracle 9
> Reporter: Karel Sommer
>
> when create criteria with associations, i get this error:
> ORA-00918: column ambiguously defined
> mapping:
> <class name="User" table="FRAME_USER" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_user_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="user_name" type="string" not-null="true"/>
> <property name="blocked" type="yes_no" not-null="true"/>
> <property name="access_logon" type="timestamp"/>
> <property name="denied_logon" type="timestamp"/>
> <property name="inactivity_time" type="long"/>
> <property name="session_count" type="long"/>
> <idbag name="terminalGroups" table="FRAME_USER_TERMINAL" fetch="join" outer-join="true">
> <collection-id column="ID" type="long">
> <generator class="sequence">
> <param name="sequence">frame_user_terminal_seq</param>
> </generator>
> </collection-id>
> <key column="id_user"/>
> <many-to-many column="id_terminal_groups" class="TerminalGroup" fetch="join" outer-join="true"/>
> </idbag>
> </class>
> <class name="TerminalGroup" table="FRAME_TERMINAL_GROUPS" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_terminal_groups_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="name" column="group_name" type="string" not-null="true"/>
> <idbag name="terminals" table="FRAME_TERMINAL_REL" fetch="join" outer-join="true">
> <collection-id column="ID" type="long" >
> <generator class="sequence">
> <param name="sequence">frame_terminal_rel_seq</param>
> </generator>
> </collection-id>
> <key column="id_term_group"/>
> <many-to-many column="id_term" class="Terminal" fetch="join" outer-join="true"/>
> </idbag>
> </class>
> <class name="Terminal" table="FRAME_TERMINAL" where="status != 'D'" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_terminal_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="status" type="char" not-null="true"/>
> <property name="mac" type="string" not-null="true"/>
> <property name="name" column="ident" type="string" not-null="true"/>
> <property name="description" type="string"/>
> code:
> session.createCriteria(User.class)
> .add(Restrictions.like("user_name", "%")
> .createCriteria("terminalGroups")
> .add( Restrictions.like("group_name", "%").
> .setProjection(Projections.rowCount())
> .uniqueResult();
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 9 months
[Hibernate-JIRA] Commented: (HHH-1123) Cannot put more than 1000 elements in a InExpression
by Duke Biswas (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1123?page=c... ]
Duke Biswas commented on HHH-1123:
----------------------------------
Hi:
I am not sure if you guys alread feagured this out but I have solution and I am attaching here
[code]
/**
* Special In Expression that handle maximum indentifiers. Note: This class
* could become an extension to Hibernate.
*
* @author BiswaD
*
*/
static class StockroomInExpression implements Criterion {
private static final long serialVersionUID = 1224146978925624808L;
protected static final int MAX_PARAMETER = 1000;
private String propertyName;
private Criterion criterion;
protected StockroomInExpression(String propertyName, String[] values) {
this.propertyName = propertyName;
this.criterion = buildSingleInCriterion(values, null, 0,
MAX_PARAMETER);
}
public TypedValue[] getTypedValues(Criteria criteria,
CriteriaQuery criteriaQuery) throws HibernateException {
return criterion.getTypedValues(criteria, criteriaQuery);
}
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
return criterion.toSqlString(criteria, criteriaQuery);
}
/**
* Recursive method that will create criterion that will have inner
* criterion with OR IN statement
*
* @param values
* @param lhs
* @param startIndex
* @param recordSize
* @return
*/
private Criterion buildSingleInCriterion(String[] values,
Criterion lhs, int startIndex, int recordSize) {
if (startIndex >= values.length) {
return lhs;
} else if (recordSize + startIndex > values.length) {
return buildSingleInCriterion(values, lhs, startIndex,
values.length - startIndex);
} else {
String[] tempArray = values;
// Create a Temp array only if the current requested record size
// is less then selected bottles total size
if (values.length > recordSize) {
tempArray = new String[recordSize];
System.arraycopy(values, startIndex, tempArray, 0,
tempArray.length);
}
Property prop = Property.forName(propertyName);
if (lhs == null) {
lhs = prop.in(tempArray);
} else {
lhs = Restrictions.or(lhs, prop.in(tempArray));
}
return buildSingleInCriterion(values, lhs, startIndex
+ recordSize, recordSize);
}
}
}
[/code]
> Cannot put more than 1000 elements in a InExpression
> ----------------------------------------------------
>
> Key: HHH-1123
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1123
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 rc2, 3.2.0.alpha1
> Environment: Oracle 9i
> Reporter: Alexis Seigneurin
> Attachments: patch.txt
>
> Original Estimate: 1 hour
> Remaining Estimate: 1 hour
>
> The number of elements that we can put in a "in" expression is limited to a certain amount (1000 for Oracle, for instance). When creating a criteria query, the org.hibernate.criterion.InExpression class should split the expression into several smaller ones.
> Attached is a patch which splits the expression by slices of 500 elements. For example, if we have 1001 elements to put in the "in" expression, the result would be :
> (entity.field in (?, ?, ?...) or entity.field in (?, ?, ?...) or entity.field in (?))
> The surrounding parantheses are useful to avoid problems with other conditions (a "and" condition taking over the one of the "or" conditions).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 9 months
[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
16 years, 9 months