Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #5768 (new)

Opened 13 years ago

Last modified 8 years ago

RFE: subclasses not loaded in Hibernate

Reported by: jamoore Owned by: jamoore
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)

See #5742 #5076

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}})

Change History (6)

comment:1 Changed 13 years ago by jmoore

  • Description modified (diff)

comment:2 Changed 12 years ago by jmoore

  • Milestone changed from Unscheduled to OMERO-Beta4.4

Just looking at this again. I was shortly before marking this as "RFE", but if we're going to do it, now (or after the Hibernate upgrade #1260) would be a good time. Any objections to letting this be a bug that slips through sprint6?

comment:3 Changed 12 years ago by jmoore

  • Owner set to jmoore

comment:4 Changed 12 years ago by jmoore

  • Summary changed from Bug: subclasses not loaded in Hibernate to RFE: subclasses not loaded in Hibernate

Moving to #1260 and marking as an RFE.

comment:5 Changed 12 years ago by jmoore

  • Milestone changed from OMERO-Beta4.4 to OMERO-Beta4.5

Perhaps something to re-evaluate when we re-do code-gen.

comment:6 Changed 8 years ago by jamoore

  • Milestone changed from 5.x to Unscheduled
Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.67322 sec.)

We're Hiring!