[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-793?page=co...
]
Rob Jellinghaus commented on HBX-793:
-------------------------------------
One additional comment: this *exact* same mapping file worked without error in Hibernate
2.1.8. We use this technique (overriding meta attributes in subclasses and property
declarations) throughout almost all our mapping files. All those usages broke with
hbm2java 3.2.0cr8. Our experience is identical to Neil Buesing's experience in this
thread:
http://forum.hibernate.org/viewtopic.php?t=956894&highlight=inherited...
I will try to dig into the 2.1.8 hbm2java source to find out why the getMetaAsString
behavior seems so radically different in 3.2.0cr8. Max, I hope you can find the time a
bit sooner now :-)
Also, if you can post a reference to how to create a patch file, it will help me -- I know
you want code changes submitted as proper patches, but I honestly don't know how to
create a proper patch file that you will accept. Any links?
Inherited meta attributes are totally broken
--------------------------------------------
Key: HBX-793
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-793
Project: Hibernate Tools
Type: Bug
Components: hbm2java
Versions: 3.2beta8
Environment: Hibernate 3.2.0cr8, Hibernate Tools 3.2.0cr8
Reporter: Rob Jellinghaus
Original Estimate: 2 days
Remaining: 2 days
Inherited / overridden meta attributes are totally broken.
By "totally broken" I mean that they are essentially concatenated in the output
template, rather than being overridden properly.
There is already an existing bug
http://opensource.atlassian.com/projects/hibernate/browse/HBX-621 that is one
manifestation of this underlying problem for <meta attribute="scope-get">
and <meta attribute="scope-get">. The exact same bug reappears for
<meta attribute="generated-class">.
Here is an example that shows the bug appearing in both attributes. The following
mapping (simplified):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="com.nimblefish.core.domain.useraccesscontrol.Permission"
table="permission">
<meta
attribute="generated-class">com.nimblefish.core.domain.generated.PermissionGen</meta>
<id column="id" name="id" type="long"
unsaved-value="null">
<meta attribute="use-in-tostring">true</meta>
<generator class="native"/>
</id>
<!-- other properties deleted -->
<joined-subclass
name="com.nimblefish.core.domain.useraccesscontrol.Role"table="role">
<meta
attribute="generated-class">com.nimblefish.core.domain.generated.RoleGen</meta>
<meta attribute="scope-set">protected</meta>
<key column="id"
foreign-key="fk_role_sub_permission"/>
<set name="grantedPermissions" inverse="true"
table="role_to_granted_permission">
<meta attribute="scope-set">public</meta>
<key column="role_id"
foreign-key="fk_granted_permission_role"/>
<many-to-many
class="com.nimblefish.core.domain.useraccesscontrol.Permission"
column="permission_id" foreign-key="fk_role_granted_permission"/>
</set>
<!-- other properties deleted -->
</joined-subclass>
</class>
</hibernate-mapping>
Produces the following class, in the directory
<out-dir>/PermissionGencom/nimblefish/core/domain/generated/RoleGen.java (that is
NOT a typo):
package
com.nimblefish.core.domain.generated.PermissionGencom.nimblefish.core.domain.generated;
// Generated Oct 27, 2006 9:58:57 PM by Hibernate Tools 3.2.0.beta8
import com.nimblefish.core.domain.useraccesscontrol.TargetObjectContainer;
import java.util.HashSet;
import java.util.Set;
/**
* RoleGen generated by hbm2java
*/
public class RoleGen extends com.nimblefish.core.domain.useraccesscontrol.Permission
implements java.io.Serializable {
// Fields
// fields deleted
protectedpublic void setGrantedPermissions(Set grantedPermissions) {
this.grantedPermissions = grantedPermissions;
}
}
You can see that:
1) The filename contains the CONCATENATION of the meta attributes and superclass name.
2) The package declaration contains the exact same conctatenation.
3) The scope of the setGrantedPermissions method contains the CONCATENATION of the
scope-set values.
I strongly believe that the root bug is related to the following method in
org.hibernate.tool.hbm2x.MetaAttributeHelper.java:
public static String getMetaAsString(org.hibernate.mapping.MetaAttribute c) {
return c==null?"":getMetaAsString(c.getValues() );
}
I don't know exactly what the collection of values of a MetaAttribute is, but I am
fairly convinced that it is the sequence of values defined up the inheritance chain. And
I am *quite* sure that getMetaAsString(Collection meta, String separator) concatenates all
the meta values together, which is exactly the behavior that is causing all these bugs.
Hibernate Tools can't go to 3.2.0GA until these issues are fixed. I will be getting
the code from Subversion and patching it myself (hackishly) on Sunday; I'll upload
details of my fix then, along with a better test case in a properly runnable
self-contained zip.
--
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