[EJB 3.0] - Etity reference problems
by oskar.carlstedt
Hi All!
I have a quite strange data model, but it has it explanation. Lets say we have the following tables in my db:
|
| -----------
| | A |
| -----------
| | Aid (pk)|
| | |
| -----------
|
|
| -----------
| | B |
| -----------
| | Bid (pk)|
| | Aid (fk)|
| | |
| -----------
|
|
| -----------
| | C |
| -----------
| | Aid (pk)|
| | Bid (fk)|
| | |
| -----------
| There is a unique constraint on the tuple (Aid, Bid)
|
|
A textual explanation of the model:
A is the master table. It has more info than the columns I described. But the most important one is the primary key Aid.
B is another table. Items in B references A, i.e. there are many B items on one A item (many-to-one).
C is a table that will point out one row in B from A. So there is a one-to-one relationship between A and B that is stored in table C.
The problem here is that we have a kind of circular reference. Is it possible to model this in EJB3 with annotation. I have tried a lot, but nothing works. I often get a NPE for OneToOne on line 135.
The classesre defined as follows:
|
| public class A {
|
| @Id
| @GeneratedValue(strategy = GenerationType.IDENTITY)
| @Column(name = "Aid")
| private Integer id;
|
| @OneToMany(cascade = CascadeType.ALL, mappedBy = "A", fetch = FetchType.LAZY)
| private List<B> Bs = new ArrayList<B>();
|
|
| @OneToOne
| @PrimaryKeyJoinColumn
| private C c = null;
|
| ...
| }
|
|
|
| public class B {
|
| @Id
| @GeneratedValue(strategy = GenerationType.IDENTITY)
| @Column(name = "Bid")
| private Integer Bid;
|
| @ManyToOne
| @JoinColumn(name = "Aid", nullable = false)
| private A a;
|
| ...
| }
|
|
| public class C {
|
| @Id
| @Column(name = "Aid")
| private Integer id;
|
| @OneToOne
| @JoinColumn(name = "Aid", nullable=false)
| private A a;
|
| @OneToOne
| @PrimaryKeyJoinColumn
| private B b;
|
| ...
| }
|
|
So, it is a problem doing this way. Does anyone know how to get it to work. I know the datamodel is a bit tricky - the explanation I have is that we want all references to A be in the same direction.
Environment:
JBoss 4.0.5.GA
JBoss EJB3 RC9 Patch
JBoss WS 1.2.0GA SP1
Database MySQL 5, no InnoDB
I would really appreciate if someone can help me
Best Regards
Oskar
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033045#4033045
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033045
17Â years, 9Â months
[Beginners Corner] - error SunJDK14IsLocalBugFix at startup
by elmut
i use mysql server 5.0 and windows xp and jboss-4.0.5.GA
evry time i do startup i find this error in log!
2007-03-29 17:17:08,531 DEBUG [org.jboss.iiop.CorbaORBService] Ignoring sunJDK14IsLocalBugFix=true due to inability to load org.jboss.iiop.SunJDK14IsLocalBugFix
java.lang.NoClassDefFoundError: com/sun/corba/se/internal/iiop/ShutdownUtilDelegate
on command line there is this message
09:53:48,390 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
--- MBeans waiting for other MBeans ---
ObjectName: jboss.ejb:service=EJBTimerService,persistencePolicy=database
State: CONFIGURED
I Depend On:
jboss.jca:service=DataSourceBinding,name=DefaultDS
ObjectName: jboss.mq:service=InvocationLayer,type=HTTP
State: CONFIGURED
I Depend On:
jboss.mq:service=Invoker
jboss.web:service=WebServer
ObjectName: jboss:service=KeyGeneratorFactory,type=HiLo
State: CONFIGURED
I Depend On:
jboss:service=TransactionManager
jboss.jca:service=DataSourceBinding,name=DefaultDS
ObjectName: jboss.mq:service=StateManager
State: CONFIGURED
I Depend On:
jboss.jca:service=DataSourceBinding,name=DefaultDS
Depends On Me:
jboss.mq:service=DestinationManager
ObjectName: jboss.mq:service=DestinationManager
State: CONFIGURED
I Depend On:
jboss.mq:service=MessageCache
jboss.mq:service=PersistenceManager
jboss.mq:service=StateManager
jboss.mq:service=ThreadPool
jboss:service=Naming
Depends On Me:
jboss.mq.destination:service=Topic,name=testTopic
jboss.mq.destination:service=Topic,name=securedTopic
jboss.mq.destination:service=Topic,name=testDurableTopic
jboss.mq.destination:service=Queue,name=testQueue
jboss.mq.destination:service=Queue,name=A
jboss.mq.destination:service=Queue,name=B
jboss.mq.destination:service=Queue,name=C
jboss.mq.destination:service=Queue,name=D
jboss.mq.destination:service=Queue,name=ex
jboss.mq:service=SecurityManager
jboss.mq.destination:service=Queue,name=DLQ
ObjectName: jboss.mq:service=PersistenceManager
State: CONFIGURED
I Depend On:
jboss.jca:service=DataSourceBinding,name=DefaultDS
Depends On Me:
jboss.mq:service=DestinationManager
ObjectName: jboss.mq.destination:service=Topic,name=testTopic
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
jboss.mq:service=SecurityManager
ObjectName: jboss.mq.destination:service=Topic,name=securedTopic
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
jboss.mq:service=SecurityManager
ObjectName: jboss.mq.destination:service=Topic,name=testDurableTopic
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
jboss.mq:service=SecurityManager
ObjectName: jboss.mq.destination:service=Queue,name=testQueue
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
jboss.mq:service=SecurityManager
ObjectName: jboss.mq.destination:service=Queue,name=A
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
ObjectName: jboss.mq.destination:service=Queue,name=B
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
ObjectName: jboss.mq.destination:service=Queue,name=C
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
ObjectName: jboss.mq.destination:service=Queue,name=D
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
ObjectName: jboss.mq.destination:service=Queue,name=ex
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
ObjectName: jboss.mq:service=Invoker
State: CONFIGURED
I Depend On:
jboss.mq:service=TracingInterceptor
jboss:service=Naming
Depends On Me:
jboss.mq:service=InvocationLayer,type=HTTP
jboss.mq:service=InvocationLayer,type=JVM
jboss.mq:service=InvocationLayer,type=UIL2
ObjectName: jboss.mq:service=TracingInterceptor
State: CONFIGURED
I Depend On:
jboss.mq:service=SecurityManager
Depends On Me:
jboss.mq:service=Invoker
ObjectName: jboss.mq:service=SecurityManager
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
Depends On Me:
jboss.mq.destination:service=Topic,name=testTopic
jboss.mq.destination:service=Topic,name=securedTopic
jboss.mq.destination:service=Topic,name=testDurableTopic
jboss.mq.destination:service=Queue,name=testQueue
jboss.mq:service=TracingInterceptor
jboss.mq.destination:service=Queue,name=DLQ
ObjectName: jboss.mq.destination:service=Queue,name=DLQ
State: CONFIGURED
I Depend On:
jboss.mq:service=DestinationManager
jboss.mq:service=SecurityManager
ObjectName: jboss.mq:service=InvocationLayer,type=JVM
State: CONFIGURED
I Depend On:
jboss.mq:service=Invoker
ObjectName: jboss.mq:service=InvocationLayer,type=UIL2
State: CONFIGURED
I Depend On:
jboss.mq:service=Invoker
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.jca:service=DataSourceBinding,name=DefaultDS
State: NOTYETINSTALLED
Depends On Me:
jboss.ejb:service=EJBTimerService,persistencePolicy=database
jboss:service=KeyGeneratorFactory,type=HiLo
jboss.mq:service=StateManager
jboss.mq:service=PersistenceManager
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033041#4033041
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033041
17Â years, 9Â months