-->
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.  [ 3 posts ] 
Author Message
 Post subject: Error when using @JoinColumnOrFormula
PostPosted: Sat Apr 16, 2011 9:15 am 
Newbie

Joined: Fri Apr 15, 2011 12:24 pm
Posts: 2
I am trying to use @JoinColumnOrFormula because I need to join second column by formula. My Hibernate version is 3.6. My annotations look like this -
@JoinColumnsOrFormulas({
@JoinColumnOrFormula(column=@JoinColumn(name = "SLITOK_REQUEST_MAJOR", nullable=false)),
@JoinColumnOrFormula( formula=@JoinFormula(value="select 1 from dual", referencedColumnName="ID_MEGA")),
@JoinColumnOrFormula(column=@JoinColumn(name = "SLITOK_REQUEST_MINOR", nullable=false))
})

When deploying my application I get following exception -
Caused by: java.lang.ClassCastException: org.hibernate.mapping.Formula incompatible with org.hibernate.mapping.Column
at org.hibernate.persister.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:297)
at org.hibernate.persister.collection.OneToManyPersister.<init>(OneToManyPersister.java:84)
at org.hibernate.persister.PersisterFactory.createCollectionPersister(PersisterFactory.java:104)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:307)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
at ru.sbrf.vklad.dao.DaoFactory.<init>(DaoFactory.java:64)
at ru.sbrf.vklad.dao.LocalDaoFactory.<init>(LocalDaoFactory.java:30)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1328)
at ru.sbrf.vklad.dao.DaoFactory.getInstance(DaoFactory.java:76)
... 49 more

Did anybody make this work, is there any workaround?


Top
 Profile  
 
 Post subject: Re: Error when using @JoinColumnOrFormula
PostPosted: Tue Apr 26, 2011 5:19 am 
Newbie

Joined: Fri Apr 15, 2011 12:24 pm
Posts: 2
Finally I find out why this error happened. I had to put JoinFormula on the end where I have ManyToOne and not to put where I have OneToMany. I have annotations like this and it works!

In class A -

@OneToMany
@JoinColumnsOrFormulas({
/* majorId */ @JoinColumnOrFormula(column=@JoinColumn(name="A_MAJOR")),
/* megaId */ @JoinColumnOrFormula(column=@JoinColumn(name="ID_MEGA")),
/* minorId */ @JoinColumnOrFormula(column=@JoinColumn(name="A_MINOR")),
})
private Set<B1> bs = new HashSet<B1>();

In class B -

@ManyToOne
@JoinColumnsOrFormulas({
/* majorId */ @JoinColumnOrFormula(column=@JoinColumn(name="A_MAJOR")),
/* megaId */ @JoinColumnOrFormula(formula=@JoinFormula(value="ID_MEGA")),
/* minorId */ @JoinColumnOrFormula(column=@JoinColumn(name="A_MINOR"))
})
private A a;


Top
 Profile  
 
 Post subject: Re: Error when using @JoinColumnOrFormula
PostPosted: Fri Mar 01, 2013 3:25 am 
Regular
Regular

Joined: Tue Feb 19, 2008 6:05 pm
Posts: 82
Could you please share your pom, I just cannot configure oneToMany joinColumnsOrFormulas as it just does not recognize it runtime and uses default joins as TABLE_A_TABLE_B with hib 3.6.4, ann 3.3.0.


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