[Biojava-dev] BioEntryRelationship problem
Mark Schreiber
markjschreiber at gmail.com
Fri May 9 05:22:02 UTC 2008
Hi -
The change you propose does seem to make sense. Richard, can you
comment on this?
Best regards,
- Mark
On Thu, May 8, 2008 at 12:55 AM, Guido Cappuccilli
<gcappuccilli at protelix.com> wrote:
>
> First of all, I am new here so I apologize in advance if I am discussing something obvious.
> Moreover I am NOT an BioJava nor Hibernate guru.
>
> I am working on a small project using BioJava (1.6) + BioSQL (1.0) (mysql 4.1.22 on Mac OS X server 10.4.11).
> I want to persist relationships between BioEntry objects.
> Storing objects to DB didn't give any problems.
>
> Sample code:
>
> Transaction tx=s.beginTransaction();
> try {
> ComparableTerm term=RichObjectFactory.getDefaultOntology().getOrCreateTerm("TestTerm");
> Namespace ns=RichObjectFactory.getDefaultNamespace();
> BioEntry parent=new SimpleBioEntry(ns, "parentbe", "pACCESSION",0);
> BioEntry child=new SimpleBioEntry(ns, "childbe", "cACCESSION",0);
> BioEntryRelationship rel=new SimpleBioEntryRelationship(parent, child, term, null);
> parent.addRelationship(rel);
> s.saveOrUpdate("BioEntry",parent );
> tx.commit();
> } catch (Exception ex) {
> tx.rollback();
> }
>
> When I started to query the db I got errors from hibernate (see below).
> After digging a little I found out that hibernate couldn't query the Bioentry_relationship table.
> Even a simple "from BioEntryRelationship" query was giving me these errors.
>
> 09:43:19,088 ERROR BasicPropertyAccessor:94 - IllegalArgumentException in class: org.biojavax.bio.SimpleBioEntryRelationship, setter method of property: object
> 09:43:19,089 ERROR BasicPropertyAccessor:98 - expected type: org.biojavax.bio.BioEntry, actual value: org.biojavax.bio.seq.SimpleRichFeature$$EnhancerByCGLIB$$91b34b44
>
>
> Checking the mapping files I found the following line in the BioEntryRelationship.hbm.xml:
>
> <many-to-one name="object" class="Feature" column="object_bioentry_id" not-null="true" cascade="persist,merge,save-update" node="@objectFeatureId" embed-xml="false"/>
>
> It looked strange to me.
> So I've changed to
>
> <many-to-one name="object" class="BioEntry" column="object_bioentry_id" not-null="true" cascade="persist,merge,save-update" node="@objectBioEntryId" embed-xml="false"/>
>
> Now I can query relationships without problems.
> Did I do the right thing or I am messing up the mapping and I am breaking something else?
> If this has been already discussed I apologize and I would appreciate a link to the original thread.
> Thank you in advance
> G.
>
>
>
>
> _______________________________________________
> biojava-dev mailing list
> biojava-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-dev
More information about the biojava-dev
mailing list