[JBoss-user] [EJB 3.0] - Re: Entity Beans extending a POJO - will I ever get this to
Hi Peter, I have successfully extended from a base class in several applications. Other problems crop up so I don't have things too easy, but not this one. You will find the solution here: http://docs.jboss.org/ejb3/app-server/tutorial/singleinheritance/single.html Also, the extended class should have no primary key - the pk is only in the base class. Do use the single table inheritance method, it works well and is amenable to some changes in your inheritance hierarchy later on, should it be needed. Hope this helps. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3922462#3922462 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3922462 --- 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
[JBoss-user] [EJB 3.0] - Re: Entity Beans extending a POJO - will I ever get this to
Please read ejb 3 spec. In PFD (chapter 2.1.9.2) it is explicitly written that any annotations on non-entity superclass are ignored. You can use @MappedSuperclass annotation to solve the problem. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3921888#3921888 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3921888 --- 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
[JBoss-user] [EJB 3.0] - Re: Entity Beans extending a POJO - will I ever get this to
I don't know if it is a bug, but I was also unable to inherit annotations. In my case I tried to inherit the @Version and @Id annotations. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3921718#3921718 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3921718 --- 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
[JBoss-user] [EJB 3.0] - Re: Entity Beans extending a POJO - will I ever get this to
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 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 getEmps() { | return emps; |} |/** | * Set the emps. | * | * @param emps The emps. | */ |public void setEmps(java.util.Collection 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
[JBoss-user] [EJB 3.0] - Re: Entity Beans extending a POJO - will I ever get this to
Could you be a bit more specific what you are trying to override and what exceptions you are getting. I have implemented inheritance from POJO's, but I also had problems inheriting annotations. Basic services worked fine. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3921708#3921708 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3921708 --- 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