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: How to map inherited properties using annotations
PostPosted: Wed Mar 25, 2009 10:20 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
Hibernate version:3.2.0

Mapping documents:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="be.rmi.intranet.db.users" default-lazy="true">
<class name="Function" table="RH_EMP_FUNCTION" lazy="false">
  <cache usage="read-write"/>
  <id name="id">
   <column name="fct_id" not-null="true" unique="true" sql-type="NUMBER"/>
      <generator class="sequence">
       <param name="sequence">RH_GENERIC_SEQ</param>
      </generator>
  </id>
  <!-- ETC..... -->
</class>
<class name="FunctionGroup" table="RH_EMP_FCT_GROUP" lazy="false">
  <cache usage="read-write"/>
  <id name="groupId">
   <column name="FCT_GROUP_ID" not-null="true" unique="true" sql-type="NUMBER"/>
      <generator class="sequence">
       <param name="sequence">RH_GENERIC_SEQ</param>
      </generator>
  </id>
  <!-- ETC..... -->
</class>


Hello,

am trying to convert from mapping file to annotations a code that has the following object hierarchy:
most objects inherit from "AbstractId", an abstract class that define the "Id" property and accessors. This is not an entity by itself. Then, in the mapping file, we map the "id" property, for each concrete class, to a corresponding table column, each table having it's own column name, different from other. See example above for 2 classes that inherit from AbstractId.

Question is, how do i, using EJB3 annotations, map this Id property for each concrete class. I have neither an Id property nor a getId method available in concrete class, considering those methods are in abstract parent class. And i can't put annotation in abstract class considering the annotations must be different for each concrete class (different column mapping) and the abstract class is not an entity.

In the database schema, abstractId does not exist, it just exist for code easiness.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.