-->
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.  [ 12 posts ] 
Author Message
 Post subject: How to map <composite-element> with EJB3 annotations?
PostPosted: Thu Aug 25, 2005 12:03 am 
Newbie

Joined: Thu Aug 05, 2004 1:54 am
Posts: 10
Location: Novosibirsk, Russia
I need to map a Set of components in EJB3.
I tried to make my component @Embeddable and declare the collection @OneToMany as follows:

Code:
@Embeddable( access=AccessType.FIELD )
public class ServiceSubscription
{
    @ManyToOne
    @JoinColumn( name="prod_id" )
    private Service m_service;
   
    @Column( name="expire_date" )
    private Date m_expirationDate;

    public ServiceSubscription()
    {
        super();
    }
}

@Entity
@Table( name="client" )
@Cache( usage=CacheConcurrencyStrategy.TRANSACTIONAL )
public class User implements Comparable
{
   ... not related code skipped ....
   
    @Embedded
    @OneToMany
    @JoinColumn( name="client_id" )
    public Set<ServiceSubscription> getSubscriptions()
    {
        return m_subscriptions;
    }
}


It produces the follwing exception:
Code:
10:44:12,732 WARN  [ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=fis-data.jar.ejb3
org.hibernate.MappingException: Association references unmapped class: com.fis.domain.ServiceSubscription
        at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:421)
        at org.hibernate.cfg.annotations.CollectionBinder$2.secondPass(CollectionBinder.java:349)
        at org.hibernate.cfg.HbmBinder$SecondPass.doSecondPass(HbmBinder.java:2544)
        at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:860)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:199)
        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:825)
        at org.hibernate.ejb.HibernatePersistence.handleCallbacks(HibernatePersistence.java:185)
        at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:176)
        at org.jboss.ejb3.entity.EntityManagerFactoryLoader.loadFactory(EntityManagerFactoryLoader.java:44)
        at org.jboss.ejb3.entity.EntityManagerFactoryLoader.loadFactory(EntityManagerFactoryLoader.java:31)
        at org.jboss.ejb3.Ejb3Module.initializeManagedEntityManagerFactory(Ejb3Module.java:290)
        at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:141)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:233)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:215)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:950)
        at $Proxy0.create(Unknown Source)
        at org.jboss.system.ServiceController.create(ServiceController.java:342)
        at org.jboss.system.ServiceController.create(ServiceController.java:281)
        at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
        at $Proxy10.create(Unknown Source)
        at org.jboss.ejb3.EJB3Deployer.create(EJB3Deployer.java:157)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
        at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:80)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
        at $Proxy11.create(Unknown Source)
        at org.jboss.deployment.MainDeployer.create(MainDeployer.java:919)
        at org.jboss.deployment.MainDeployer.create(MainDeployer.java:909)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:773)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:737)
        at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
        at $Proxy6.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:325)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:483)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)


How to do it properly?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 7:47 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Funny, I've finished implementing that 2 hours before your post.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 8:06 am 
Newbie

Joined: Thu Aug 05, 2004 1:54 am
Posts: 10
Location: Novosibirsk, Russia
I'm using version that comes with JBoss 4.0.3RC1.
Could you please give me an advice on how should I do it now, before your changes go in production? Should I remap association table as entity and add id there?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 8:11 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 19, 2005 8:13 pm 
Newbie

Joined: Mon Sep 19, 2005 8:11 pm
Posts: 5
Remapping is not really appropriate for me, when will the change be available ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 5:24 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
having an entity instead of a composite element makes no difference in DB nor in OO, only the mapping change.
Anyway, this is doable with the latest release.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 7:40 am 
Beginner
Beginner

Joined: Mon Sep 12, 2005 3:27 am
Posts: 48
Is there any special @Annotation for this composite-element or how can this be done ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 12:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Everything is in the reference doc :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: EJB3 Ternary associations?
PostPosted: Fri Sep 30, 2005 4:31 pm 
Newbie

Joined: Mon Mar 07, 2005 6:55 pm
Posts: 2
:( I'm having trouble finding an example of this in the reference docs of Hibernate Annotations.

¿Does anybody has a link with an example of a ternary associacion mapping using @annotations?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 7:53 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It is said that many to one on a embedded object are not yet supported. So, this is currently impossible

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 4:37 pm 
Newbie

Joined: Mon Mar 13, 2006 7:07 pm
Posts: 8
is this now supported? and if so... how?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 4:57 pm 
Newbie

Joined: Mon Mar 13, 2006 7:07 pm
Posts: 8
got it...

use

@CollectionOfElements

rather than

@OneToMany


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 

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