-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with split entity's attributes for 2 tables
PostPosted: Wed Jun 27, 2007 5:36 pm 
Newbie

Joined: Wed Jun 27, 2007 4:29 pm
Posts: 1
Hi All.
Its my first Post here, and i dont speak english very well.
I have a Entity named Descarga wich have 4 attributes:
->idDescarga
->nome
->sigla
->intensidade
The entity Descarga is mapped by the descarga table. But the attribute intensidade is in another table, called descargaEvento wich is a association table.
So, when i save the entity Descarga i need to save the intensidade attribute into the descargaEvento table. Follows my entity Class and tables.

CREATE TABLE descarga (
idDescarga: int,
nome: Varchar(80),
sigla: Varchar(10),
primary_key(idDescarga)
)

CREATE TABLE descargaEvento(
evento_idEvento: int,
descarga_idDescarga: int,
intensidade: int,
foreign_key(evento_idEvento) references (evento.idEvento),
foreign_key(descarga_idDescarga) references (descarga.idDescarga),
primary_key(evento_idEvento, descarga_idDescarga)
)

And the Class Code bellow:

@Entity
@Table(name="descarga")
@SequenceGenerator(name="SEQ_DESCARGA" ,sequenceName = "\"descarga_idDescarga_seq\"", allocationSize = 1)
@SecondaryTable(name="\"descargaEvento\"", pkJoinColumns={
@PrimaryKeyJoinColumn(name="\"descarga_idDescarga\"", referencedColumnName="\"idDescarga\"")})
public class DescargaEvento implements Serializable{

private static final long serialVersionUID = 1L;
private int idDescarga;
private int intensidade;
private String nome;
private String sigla;

@Id
@Column(name = "\"idDescarga\"")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_DESCARGA")
public int getIdDescarga() {
return idDescarga;
}
public void setIdDescarga(int idDescarga) {
this.idDescarga = idDescarga;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getSigla() {
return sigla;
}
public void setSigla(String sigla) {
this.sigla = sigla;
}
@Column(table="\"descargaEvento\"")
public int getIntensidade() {
return intensidade;
}
public void setIntensidade(int intensidade) {
this.intensidade = intensidade;
}

}

When i try to save this entity, i get the following error:

Caused by: org.hibernate.MappingException: Unable to find logical column name from physical name idEvento in table evento
at org.hibernate.cfg.Mappings.getLogicalColumnName(Mappings.java:514)
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:211)
at org.hibernate.cfg.annotations.EntityBinder.createPrimaryColumnsToSecondaryTable(EntityBinder.java:471)
at org.hibernate.cfg.annotations.EntityBinder.finalSecondaryTableBinding(EntityBinder.java:440)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:770)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1143)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:362)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:900)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:815)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:273)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)


What is that exception, and how can i solve?
PS: Sorry about my poor english.
Thanks.[/code]

_________________
Software Livre.
Adote esta Idéia!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 11:04 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Why are you escaping all the quotes?
Try and remove \"

_________________
Emmanuel


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