-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problems with Mapping Exception
PostPosted: Tue Oct 24, 2006 5:49 pm 
Newbie

Joined: Tue Oct 24, 2006 5:38 pm
Posts: 5
Hi guys,

I'm having problems with my project, I have a table called CIDADES and in this table there is a column called COD_CIDADE which is CIDADES Primary key.

My EJB Cidades is Mapped like this:
...

@Id
@Column(name="COD_CIDADE", nullable=false)
public Long getCodCidade() {
return codCidade;
}

...

and for some reason hibernate seems to don't find the column COD_CIDADE but it exists. I get the following Exception:


HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Unable to find column with logical name: CIDADES.COD_CIDADE in org.hibernate.mapping.Table(CIDADES) and its related supertables and secondary tables
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)

root cause

org.hibernate.MappingException: Unable to find column with logical name: CIDADES.COD_CIDADE in org.hibernate.mapping.Table(CIDADES) and its related supertables and secondary tables
org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:364)
org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:88)
org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:63)
org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1210)
br.com.quasar.util.dao.HibernateUtil.<init>(HibernateUtil.java:24)
br.com.quasar.util.dao.HibernateUtil.getInstance(HibernateUtil.java:17)
br.com.quasar.util.dao.DaoFactory.<init>(DaoFactory.java:19)
br.com.quasar.logica.UserLogic.adiciona(UserLogic.java:23)
br.com.quasar.logica.MyActionListener4.processAction(MyActionListener4.java:27)
javax.faces.event.ActionEvent.processListener(ActionEvent.java:57)
javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:649)
javax.faces.component.UICommand.broadcast(UICommand.java:297)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
_____________________________________________________________

I'm using oracle 10g database, tomcat 5.x, java 1.5 and hibernate 3.2.cr4

I'd really appreciate some help =)
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 25, 2006 11:59 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you need to show all the mapping that reproduce the issue, but please make is as minimal as possible, posting more that 2 pages of code is unreadable

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 25, 2006 3:30 pm 
Newbie

Joined: Tue Oct 24, 2006 5:38 pm
Posts: 5
Hi Emmanuel,

The first problem was with the mapping ManyToOne, had nothing to do with this class.

Now I'm having other problems. Actually those classes were gererated by Jdeveloper because there were too many tables to write the EJBs one by one, and Jdeveloper obsviously does not map the classes according to hibernate documentation.
I've read the documentation and i don't understand how should i map a ManyToOne relationship when there are more than one JoinColumns. For instance: The are two Classes Teacher, and Students. The Teachers table primary key is composed by two columns firstName and lastName:

class Student { ...

@ManyToOne
@JoinColumns({
@JoinColumn(name="FIRST_NAME"),
@JoinColumn(name="LAST_NAME")
})
public Teacher getTeacher() {
return this.teacher
}
...
}

class Teacher { ...

@OneToMany(mappedBy="teacher")
public Collection<Student> getStudentCollection() {
return studentCollection;
}
...
}

That's how i'm mapping in my classes but i guess there is something wrong because i get this exception:

javax.servlet.ServletException: A Foreign key refering br.com.teste.model.Teacher from br.com.teste.model.Student has the wrong number of column. should be 3
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)

root cause

org.hibernate.AnnotationException: A Foreign key refering br.com.teste.model.Teacher from br.com.teste.model.Student has the wrong number of column. should be 3
org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:255)
org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:64)
org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1210)

Thanks for your time =)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 25, 2006 4:53 pm 
Newbie

Joined: Tue Oct 24, 2006 5:38 pm
Posts: 5
Emmanuel I solved my problem!
Was something ridiculous, i made a mistake in my TeacherPK class, there were 3 properties over there!

bye


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