-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Template pattern causing odd results in Entity object
PostPosted: Sat May 07, 2011 1:44 pm 
Newbie

Joined: Thu Feb 03, 2011 4:09 pm
Posts: 8
Hi all. I have an abstract Entity class, Event, and concrete classes like EventVideo, EventPhoto, etc that extend it. I want to place the object id of the video, photo, etc into the Event table in a column named "item". In entity I have
Code:
    @Column(name = "item")
    public Long getItem() {return getObjectId();} // abstract, template pattern
    public abstract Long getObjectId();


and in EventVideo
Code:
   @Override
   public Long getObjectId() {
      return mediaVideo.getMediaId();
   }


I would think this would attempt to write to event.item a value of the mediaId, but I get the error
Code:
[org.hibernate.util.JDBCExceptionReporter] ERROR: column event6_.mediavideo does not exist

When I look at the SQL insert, it never mentions the column "item", but thinks there is a column named "mediavideo".

If I however put the following in EventVideo and remove item from Event, all works perfectly.
Code:
   @JoinColumn(name = "item")
   @ManyToOne(fetch = FetchType.EAGER)
   private MediaVideo mediaVideo;
   public MediaVideo getMediaVideo() {return mediaVideo;}
   public void setMediaVideo(MediaVideo mediaVideo) {this.mediaVideo = mediaVideo;}


I would Much rather use the broken solution because then I can enforce adding the getObjectId on the concrete method. Any ideas?

Thanks everyone for you help!


Top
 Profile  
 
 Post subject: Re: Template pattern causing odd results in Entity object
PostPosted: Sat May 07, 2011 1:45 pm 
Newbie

Joined: Thu Feb 03, 2011 4:09 pm
Posts: 8
Oopps...forgot to mention that this is with Hibernate 3.6.1 Final. Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.