Here is the Base Class

  | public class BaseDeptDTOImpl implements Serializable {
  | 
  |     private static final Log log = LogFactory.getLog(BaseDeptDTO.class);
  |     
  | 
  |    /** Primary key. */
  |    private int deptId;
  | 
  |    /**
  |     * auto_increment
  |     *
  |     * Get the primary key.
  |     *
  |     * @return The primary key.
  |     */
  |    @javax.persistence.Id 
@javax.persistence.GeneratedValue(strategy=javax.persistence.GenerationType.AUTO)
  |    @javax.persistence.Column(name = "dept_id")
  |    public int getDeptId() {
  |       return deptId;
  |    }
  | 
  |    /**
  |     * auto_increment
  |     *
  |     * Set the primary key.
  |     *
  |     * @param deptId The primary key.
  |     */
  |    public void setDeptId(int deptId) {
  |       this.deptId = deptId;
  |    }
  | 
  |    /** Regular field. */
  |    private java.lang.String deptName;
  | 
  |    /**
  |     * Get the deptName.
  |     *
  |     * @return The deptName.
  |     */
  |    @javax.persistence.Column(name = "dept_name")
  |    public java.lang.String getDeptName() {
  |       return deptName;
  |    }
  | 
  |    /**
  |     * Set the deptName.
  |     *
  |     * @param deptName The deptName.
  |     */
  |    public void setDeptName(java.lang.String deptName) {
  |       this.deptName = deptName;
  |    }
  | 
  |    /** Association. */
  |    private 
java.util.Collection<tv.probability.referenceimplementation.dto.EmpDTO> emps;
  |    /**
  |     * Get the emps.
  |     *
  |     * @return The emps.
  |     */
  |    @javax.persistence.OneToMany(cascade = 
javax.persistence.CascadeType.ALL, fetch = javax.persistence.FetchType.EAGER)
  |    @javax.persistence.JoinColumn(name = "dept_id")
  |    public 
java.util.Collection<tv.probability.referenceimplementation.dto.EmpDTO> 
getEmps() {
  |       return emps;
  |    }
  |    /**
  |     * Set the emps.
  |     *
  |     * @param emps The emps.
  |     */
  |    public void 
setEmps(java.util.Collection<tv.probability.referenceimplementation.dto.EmpDTO> 
emps) {
  |       this.emps = emps;
  |    }
  | }
  | 

and here is the extending class


  | @javax.persistence.Entity
  | @org.hibernate.annotations.Entity(dynamicInsert = true)
  | @javax.persistence.Table(name = "dept")
  | public class DeptDTOImpl extends BaseDeptDTOImpl implements DeptDTO {
  |     private static final Log log = LogFactory.getLog(DeptDTOImpl.class);
  | 
  |    /** Primary key. */
  |    private int deptId;
  | 
  |    /**
  |     * auto_increment
  |     *
  |     * Get the primary key.
  |     *
  |     * @return The primary key.
  |     */
  |    @javax.persistence.Id 
@javax.persistence.GeneratedValue(strategy=javax.persistence.GenerationType.AUTO)
  |    @javax.persistence.Column(name = "dept_id")
  |    public int getDeptId() {
  |       return deptId;
  |    }
  | 
  |    /**
  |     * auto_increment
  |     *
  |     * Set the primary key.
  |     *
  |     * @param deptId The primary key.
  |     */
  |    public void setDeptId(int deptId) {
  |       this.deptId = deptId;
  |    }
  | }
  | 

This compiles and runs, but the inherited deptName is not persisted to the 
database, it is ommited from the SQL entirely.
If I add the entity annotations to the Base class:


  | @javax.persistence.Entity
  | @org.hibernate.annotations.Entity(dynamicInsert = true)
  | @javax.persistence.Table(name = "dept")
  | 
I get the exception:


  | FATAL 05-02 09:00:24,776 
(PersistenceXmlLoader.java:parsePersistenceUnit:101)  -refImplDB JTA
  | ERROR 05-02 09:00:28,605 (AbstractController.java:incrementState:350)  
-Error installing to Start: 
name=persistence.units:jar=embeddable-ejb.jar,unitName=refImplDB state=Create
  | org.hibernate.AnnotationException: Unable to define/override @Id(s) on a 
subclass: tv.probability.referenceimplementation.dto.DeptDTOImpl
  | 


btw. I am running this using EMbeddable EJBs and JUnit.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3921717#3921717

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3921717


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to