[EJB 3.0] - EntityBean with SecondaryTable
by Ceene
I get an error-message from JBoss
| 11:18:52,328 INFO [EntityBinder] Bind entity tcejb.LOV_Right on table LOV_USER_RIGHT
| 11:18:52,328 INFO [EntityBinder] Adding secondary table to entity tcejb.LOV_Right -> LOV_RIGHT_TYP
| 11:18:52,359 WARN [ServiceController] Problem starting service persistence.units:jar=LoginBean.jar,unitName=tcdb
| org.hibernate.AnnotationException: Cannot find the expected secondary table: no LOV_USER_RIGHT available for tcejb.LOV_Right
| at org.hibernate.cfg.Ejb3Column.getJoin(Ejb3Column.java:293)
|
Why can't JBoss find the table? I have all Anotiations
| package tcejb;
|
| import javax.persistence.*;
|
| @Entity
| @NamedQueries({
| @NamedQuery(name="LOV_Right.findRight",
| query= "SELECT a FROM LOV_Right a " +
| "WHERE a.lov_urt_right_rule_sign = a.lov_rt_right_rule_sign " +
| "AND a.lov_urt_status_sign = 'A' " +
| "AND a.lov_urt_user = :name ")
| })
| @Table(name="LOV_USER_RIGHT")
| @SecondaryTable(name="LOV_RIGHT_TYP",
| pkJoinColumns={
| @PrimaryKeyJoinColumn(name="LOV_RT_RIGHT_RULE_SIGN")})
| public class LOV_Right implements java.io.Serializable {
|
| private static final long serialVersionUID = 1;
|
|
| private String lov_urt_user;
| private int lov_urt_right_rule_sign;
|
| private int lov_rt_right_rule_sign;
| private int lov_rt_right_class;
| private String lov_rt_right_read;
| private String lov_rt_right_confirm;
| private String lov_rt_right_update;
| private String lov_rt_right_new;
| private String lov_rt_right_excel_reason;
|
|
| @Id
| @Column(name="LOV_URT_USER", table="LOV_USER_RIGHT")
| public String getlov_urt_user() {return lov_urt_user;}
| public void setlov_urt_user(String lov_urt_user) {this.lov_urt_user = lov_urt_user;}
|
| @Id
| @Column(name="LOV_URT_RIGHT_RULE_SIGN", table="LOV_USER_RIGHT")
| public int getlov_urt_right_rule_sign() {return lov_urt_right_rule_sign;}
| public void setlov_urt_right_rule_sign(int lov_urt_right_rule_sign) {this.lov_urt_right_rule_sign = lov_urt_right_rule_sign;}
|
| @Id
| @Column(name="LOV_RT_RIGHT_RULE_SIGN", table="LOV_RIGHT_TYP")
| public int getlov_rt_right_rule_sign() {return lov_rt_right_rule_sign;}
| public void setlov_rt_right_rule_sign(int lov_rt_right_rule_sign) {this.lov_rt_right_rule_sign = lov_rt_right_rule_sign;}
|
| @Column(name="LOV_RIGHT_CLASS", table="LOV_RIGHT_TYP")
| public int getlov_rt_right_class() {return lov_rt_right_class;}
| public void setlov_rt_right_class(int right_class) {this.lov_rt_right_class = right_class;}
|
| @Column(name="LOV_RT_RIGHT_READ", table="LOV_RIGHT_TYP")
| public String getlov_rt_right_read() {return lov_rt_right_read;}
| public void setlov_rt_right_read(String right_read) {this.lov_rt_right_read = right_read;}
|
| @Column(name="LOV_RT_RIGHT_CONFIRM", table="LOV_RIGHT_TYP")
| public String getlov_rt_right_confirm() {return lov_rt_right_confirm;}
| public void setlov_rt_right_confirm(String right_confirm) {this.lov_rt_right_confirm = right_confirm;}
|
| @Column(name="LOV_RT_RIGHT_UPDATE", table = "LOV_RIGHT_TYP")
| public String getlov_rt_right_update() {return lov_rt_right_update;}
| public void setlov_rt_right_update(String right_update) {this.lov_rt_right_update = right_update;}
|
| @Column(name="LOV_RT_RIGHT_NEW", table="LOV_RIGHT_TYP")
| public String getlov_rt_right_new() {return lov_rt_right_new;}
| public void setlov_rt_right_new(String right_new) {this.lov_rt_right_new = right_new;}
|
| @Column(name="LOV_RT_RIGHT_EXCEL_REASON", table="LOV_RIGHT_TYP")
| public String getlov_rt_right_excel_reason() {return lov_rt_right_excel_reason;}
| public void setlov_rt_right_excel_reason(String right_excel_reason) {this.lov_rt_right_excel_reason = right_excel_reason;}
|
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135563#4135563
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4135563
18 years, 1 month
[EJB 3.0] - NonUniqueObjectException
by Subhash.Bhushan
Hi,
I am trying to use a OneToMany relationship between my MemberDetail Class and its addresses. Here is the code:
MemberDetail.java:
| public class MemberDetail implements java.io.Serializable {
| .
| .
| .
| private Collection<Address> addresses = new ArrayList<Address>();
| .
| .
| .
| @OneToMany(cascade={CascadeType.ALL}) @JoinColumn(name="LINKER_ID")
| public Collection<Address> getAddresses() {
| return addresses;
| }
| public void setAddresses(Collection<Address> addresses) {
| this.addresses = addresses;
| }
| .
| .
| .
|
Address.java:
| public class Address implements java.io.Serializable {
| .
| .
| .
| private int id;
| .
| .
| .
| @Id
| @Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true)
| public int getId() {
| return this.id;
| }
| public void setId(int id) {
| this.id = id;
| }
| .
| .
| .
|
The Address class does not have any reference to MemberDetail class.
Creating the Member Detail:
| memberDetail.setProfileId(profile.getProfileId());
| memberDetail.setStatus('R');
| memberDetail.setModificationNum(1);
|
| officeAddress.setActive('R');
| officeAddress.setModificationNum(1);
| personalAddress.setActive('R');
| personalAddress.setModificationNum(1);
| memberDetail.getAddresses().add(officeAddress);
| memberDetail.getAddresses().add(personalAddress);
| try {
| manager.persist(memberDetail);
| return true;
| }catch(Exception exc){
| exc.printStackTrace();
| return false;
| }
|
I get the following error upon persisting:
anonymous wrote :
| 19:37:16,671 ERROR [STDERR] javax.persistence.PersistenceException: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.justbooks.common.entities.Address#0]
| 19:37:16,687 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
| 19:37:16,687 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:218)
| 19:37:16,687 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManager.persist(TransactionScopedEntityManager.java:182)
| 19:37:16,687 ERROR [STDERR] at com.justbooks.security.activities.ManageProfileBean.createProfile(ManageProfileBean.java:95)
|
I am using EJB 3.0 persistence with J2EE 1.4/J2SE 5. I assume that Address IDs should be autogenerated. I am using MySQL DB and I have marked the field for autogenerate.
I am sure I am doing something wrong, but not able to pinpoint the problem.
Thanks in advance. Any clues are welcome.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135556#4135556
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4135556
18 years, 1 month
[JBossCache] - Re: JBOSS Cache vs Gigaspaces
by bahata
Hi
I tried Gigaspace , ehcache, jboss pojo cache and some other caching solutions to find out which one was more suitable to my appliction.
Atlast I sticked to JBoss pojo cache because:
1) Hibernate was used in our project as ORM , and we loaded all the data
from DB using hibernate association so that the internal object references were maintained . But GIGASPACE DOES NOT SUPPORT HIBERNATE ASSOCIATION to maintain the object graph unless you use it as hibernate second level cache.
2) Also it does not support : object graph maintenance through object reference (if I am not wrong). UID is used to recreate the object references if needed, through transient objects
If you do not have hibernate in your application ,or do not have complex objects, (none of your non-primitive object refers to another non-primitive object , which is quite unlikely), you can go for gigaspace.
The good things with Gigaspace is that it supports partitioning, master-local topology ,and various other features.
JBoss pojo cache is good in the sense that it supports maintaining the complex object graph with less effort.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135551#4135551
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4135551
18 years, 1 month