-->
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.  [ 11 posts ] 
Author Message
 Post subject: Repeated column in mapping
PostPosted: Sun Jan 02, 2005 12:13 am 
Newbie

Joined: Sun Dec 26, 2004 4:39 pm
Posts: 14
JBoss version:4.0.1 RC1


I have a composite primary key made up of two Integer fields and I was able to create a PK class from the JBoss EJB 3.0 example. However my situation is different from the example in that one of the fields of the primary key is the JoinColumn to another table. This causes Jboss Hibernate to return a error, "Repeated column in mapping"

According to Hibernate discussions this problem can be fixed by marking the OneToMany as "update=false, insert=false" however this doesn't seem to be part of the 3.0 spec.

Is there a Hiberate fix for this problem?

Thanks.


2005-01-01 20:02:55,842 ERROR [org.hibernate.cfg.Configuration] Could not compile the mapping document
org.hibernate.PropertyNotFoundException: field not found: parentIndex
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:89)
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:96)
at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:104)
at org.hibernate.util.ReflectHelper.getter(ReflectHelper.java:90)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:78)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:217)
at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:1544)
at org.hibernate.cfg.HbmBinder.bindComponent(HbmBinder.java:1325)
at org.hibernate.cfg.HbmBinder.bindCompositeId(HbmBinder.java:1224)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:498)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:1830)
at org.hibernate.cfg.Configuration.add(Configuration.java:340)
at org.hibernate.cfg.Configuration.addXML(Configuration.java:297)
at org.jboss.ejb3.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:131)
at org.jboss.ejb3.Ejb3Module.createHibernateSessionFactory(Ejb3Module.java:206)
at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:218)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
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:144)
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:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:416)
at sun.reflect.GeneratedMethodAccessor5.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:144)
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:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:175)
at $Proxy16.start(Unknown Source)
at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:168)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:944)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:755)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:718)
at sun.reflect.GeneratedMethodAccessor37.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:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:175)
at $Proxy8.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:463)
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)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 02, 2005 5:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hard to do anything without failing code

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: I've changed the JBoss provided example slightly
PostPosted: Sun Jan 02, 2005 11:06 am 
Newbie

Joined: Sun Dec 26, 2004 4:39 pm
Posts: 14
Thanks for the response. Here is an example

Code:
@Entity
public class CustomerFlight implements java.io.Serializable
{
   CustomerFlightPK pk;
   Flight flight;

   public CustomerFlight()
   {
   }

   @Id(generate = GeneratorType.NONE)
   @Dependent({
   @DependentAttribute(name = "id"),
   @DependentAttribute(name = "flight_id")
   })
   public CustomerPK getPk()
   {
      return pk;
   }

   public void setPk(CustomerPK pk)
   {
      this.pk = pk;
   }

   @Transient
   public String getName()
   {
      return pk.getName();
   }

   @ManyToOne
   @JoinColumns({@JoinColumn(name = "flight_id")})

   public Flight getFlight()
   {
      return flight;
   }

   public void setFlight(Flight flight)
   {
      this.flight = flight;
   }

}


Top
 Profile  
 
 Post subject: lets try that again
PostPosted: Sun Jan 02, 2005 11:08 am 
Newbie

Joined: Sun Dec 26, 2004 4:39 pm
Posts: 14
Code:
@Entity
public class CustomerFlight implements java.io.Serializable
{
   CustomerFlightPK pk;
   Flight flight;

   public CustomerFlight()
   {
   }

   @Id(generate = GeneratorType.NONE)
   @Dependent({
   @DependentAttribute(name = "id"),
   @DependentAttribute(name = "flight_id")
   })
   public CustomerFlightPK getPk()
   {
      return pk;
   }

   public void setPk(CustomerFlightPK pk)
   {
      this.pk = pk;
   }

   @ManyToOne
   @JoinColumn(name = "flight_id")

   public Flight getFlight()
   {
      return flight;
   }

   public void setFlight(Flight flight)
   {
      this.flight = flight;
   }

}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 03, 2005 10:31 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You'll not be able to fix it using the EJB3 annotations. I think we should forbid what you want or enable the update/insert attribute at the spec level.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 03, 2005 8:09 pm 
Newbie

Joined: Sun Dec 26, 2004 4:39 pm
Posts: 14
Should it be possible to create the relationship under the CustomerPK class instead and expose it throught @Transient methods to the Customer class?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 04, 2005 6:13 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You mean
Code:
@Transient public getLink() {
    getId().getLink();
}


Actually you can :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 05, 2005 10:00 pm 
Newbie

Joined: Sun Dec 26, 2004 4:39 pm
Posts: 14
Emmanuel,

Did you get my example? I sent you an email where it doesn't work.

BTW. How do you upload attachements to this board?

Thanks,

Gray


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 05, 2005 10:08 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
There is no need for attachments of any kind. If you can not express an issue using the artefacts listed in our textarea form, it should not be discussed on a public forum until you isolate the problem further.

I doubt Emmanuel has the time to work on your application.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 1:46 am 
Newbie

Joined: Sun Dec 26, 2004 4:39 pm
Posts: 14
Christian

Thanks for your response however I'm not asking him to work on my issue. He responded to my posted with certain information about the capability of Hibernate that doesn't seem to match the reality of my experience. For the purpose of disseminating accurate information to your user community, it would be nice for you to actually provide verifiable information on this board.

Thanks,

Gray


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 3:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Actually I hadn't had time to look at your case. You should report this bug to Bill anyway http://www.jboss.org/products/ejb3/jira.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 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.