-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping an interface
PostPosted: Sat Sep 10, 2011 10:36 pm 
Newbie

Joined: Sat Sep 10, 2011 10:22 pm
Posts: 8
I have a simple interface with id, version and name. A single class implements this interface.

I want to create a mapping file that is based on the interface and results in Hibernate persisting the implementation class. The mapping files I have created so far use joined-subclass. They result in multiple insert statements and missing fields that violate non-null integrity constraints.

Listed below are the interface and my current attempt at a mapping file.

Any suggestions on the mapping file would be greatly appreciated.

Code:
public interface Foo {
  public Long getId();
  public void setId(Long id);
  public Integer getVersion();
  public void setVersion(Integer version);
  public String getName();
  public void setName(String name);
}


Code:
<hibernate-mapping>
   <class abstract="true" name="com.sample.model.Foo" table="FOO">
      <id name="id" type="java.lang.Long">
         <column name="ID" />
         <generator class="native" />
      </id>
      <version column="VERSION" generated="never" insert="false"
         name="version" type="integer" />
      <property generated="never" lazy="false" name="name"
         type="java.lang.String">
         <column name="NAME" />
      </property>
      <joined-subclass name="com.sample.model.internal.FooImpl">
         <key column="id" />
      </joined-subclass>
   </class>
</hibernate-mapping>


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

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.