Task #5768 (new)
Opened 13 years ago
Last modified 8 years ago
Bug: subclasses not loaded in Hibernate — at Version 1
Reported by: | jamoore | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | Unscheduled |
Component: | ORM | Version: | n.a. |
Keywords: | n.a. | Cc: | cxallan, jburel |
Resources: | n.a. | Referenced By: | n.a. |
References: | n.a. | Remaining Time: | n.a. |
Sprint: | n.a. |
Description (last modified by jmoore)
Two possible solutions are to properly set FetchType.EAGER on abstract classe (see patch below) or to more full use the results of object.toString() to workaround the _javassist_$$_... class wrappers. Chris also mentioned using interfaces.
~/git $ git diff components/dsl/ diff --git a/components/dsl/resources/ome/dsl/object.vm b/components/dsl/resources/ome/dsl/object.vm index ea6cfb2..abd91c9 100644 --- a/components/dsl/resources/ome/dsl/object.vm +++ b/components/dsl/resources/ome/dsl/object.vm @@ -390,22 +390,26 @@ implements java.io.Serializable, IObject public final static String PERMS_FILTER_${prop.nameUpper} = "${pfilter}_${prop.nameUpper}"; #end +#set( $fetchType = "LAZY") +#if($prop.actualTarget.abstract) +#set( $fetchType = "EAGER" ) +#end /** * returns ${prop.name} . You should not modify this collection unless you * know what you are doing. Use the iterate method instead. * ## #if($prop.ordered) - * one-to-many List ${type.id}.${prop.name} (${prop.type}) + * one-to-many List ${type.id}.${prop.name} (${prop.type}) // $prop.actualType // $prop.actualType.abstract * Values are indexed by the column "index" on ${prop.type} */ @javax.persistence.JoinColumn(name="${type.inverse($prop)}", nullable=false) - @javax.persistence.OneToMany(fetch=javax.persistence.FetchType.LAZY, cascade={${cascadeEjb}}) + @javax.persistence.OneToMany(fetch=javax.persistence.FetchType.${fetchType}, cascade={${cascadeEjb}}) @org.hibernate.annotations.IndexColumn(name="${prop.inverse}_index", nullable=false) #else - * one-to-many Set ${type.id}.${prop.name} (${prop.type}) + * one-to-many Set ${type.id}.${prop.name} (${prop.type}) // $prop.actualType // $prop.actualType.abstract */ - @javax.persistence.OneToMany(mappedBy="${prop.inverse}", fetch=javax.persistence.FetchType.LAZY, cascade={${cascadeEjb}}) + @javax.persistence.OneToMany(mappedBy="${prop.inverse}", fetch=javax.persistence.FetchType.${fetchType}, cascade={${cascadeEjb}}) #end @org.hibernate.annotations.Cascade({${cascadeHibCollection}}) ## @@ -927,11 +931,13 @@ implements java.io.Serializable, IObject #end## End isLink #elseif($prop.foreignKey)## REGULAR M-1 ##################################TYPE #set( $fetchType = "LAZY") -#if($prop.actualType.abstract) +#if($prop.actualTarget.abstract) #set( $fetchType = "EAGER" ) #end /** * Many-to-one field ${type.id}.${prop.name} (${prop.type}) + * Type: $prop.actualType.abstract + * Target: $prop.actualTarget.abstract */ @javax.persistence.ManyToOne(fetch = javax.persistence.FetchType.${fetchType}, cascade = {${cascadeEjb}}, targetEntity = ${prop.type}.class) @org.hibernate.annotations.Cascade({${cascadeHib}})
Note: See
TracTickets for help on using
tickets.
You may also have a look at Agilo extensions to the ticket.