-->
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.  [ 1 post ] 
Author Message
 Post subject: mapping too complex make Hibernate fail??? (LONG)
PostPosted: Fri Aug 25, 2006 6:44 am 
Newbie

Joined: Wed May 31, 2006 6:40 am
Posts: 19
Hibernate version:
I'm using standard jboss 4.04 ga: it says
11:55:52,108 INFO [Version] Hibernate EntityManager 3.2.0.CR1
11:55:52,139 INFO [Version] Hibernate Annotations 3.2.0.CR1
11:55:52,155 INFO [Environment] Hibernate 3.2 cr2

Full stack trace of any exception that occurs:

Name and version of the database you are using:
SQL server 2005

The generated SQL (show_sql=true): taken from exception
select distinct dataevento0_.codice as codice13_0_, postioccup1_.id_PostiOccupatiPerDataEvento as id1_33_1_, dataevento0_.codice_evento as codice14_13_0_, dataevento0_.provincia as provincia13_0_, dataevento0_.citta as citta13_0_, dataevento0_.nazione as nazione13_0_, dataevento0_.datainizio as datainizio13_0_, dataevento0_.orainizio as orainizio13_0_, dataevento0_.I_incidenza as I7_13_0_, dataevento0_.nominativo as nominativo13_0_, dataevento0_.id_ConfigurazioneLocale as id15_13_0_, dataevento0_.datainizioprevendita as datainiz9_13_0_, dataevento0_.I_imponibileintrattenimenti as I10_13_0_, dataevento0_.attivo as attivo13_0_, dataevento0_.I_tipotassazione as I12_13_0_, dataevento0_.stato as stato13_0_, postioccup1_.codice_data_evento as codice4_33_1_, postioccup1_.codice_titolo as codice5_33_1_, postioccup1_.id_BigliettoAbbonamento as id2_33_1_, postioccup1_.id_abbonamento as id6_33_1_, postioccup1_.id_ConfigurazioneLocale as id7_33_1_, postioccup1_.codice_ordine_posto as codice8_33_1_, postioccup1_.id_fila as id9_33_1_, postioccup1_.codice_posto as codice3_33_1_, postioccup1_.codice_data_evento as codice4_0__, postioccup1_.id_PostiOccupatiPerDataEvento as id1_0__ from DBServerFarm.DBS3.DataEvento dataevento0_ left outer join DBServerFarm.DBS3.PostiOccupatiPerDataEvento postioccup1_ on dataevento0_.codice=postioccup1_.codice_data_evento where dataevento0_.codice=?

Debug level Hibernate log excerpt:
12:06:45,233 INFO [LongType] could not read column value from result set: codice8_33_1_; The value supplied cannot be converted to BIGINT.
12:06:45,233 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 22000
12:06:45,233 ERROR [JDBCExceptionReporter] The value supplied cannot be converted to BIGINT.
12:06:55,108 ERROR [STDERR] errore :javax.ejb.EJBTransactionRolledbackException: javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not execute query

Let's start from the end... codice8_33_1_ is an alfanumeric varchar(2).... so no surprise it's not converted to BIGINT....

BUT!!!!

i checked the annotations.... the FK... it's correct!!!
DBServerFarm.DBS3.PostiOccupatiPerDataEvento.codice_ordine_posto
is connected to the right place... a varchar(2) PK from a very simple table... 2 columns: code, description
or i mean... it's in a 2 col FK....

id_ConfigurazioneLocale, codice_ordine_posto to OrdinePostoPerConfigurazioneLocali and there is a single col FK to OrdinePosto

so i really don't understand how hibernate try to convert to bigint...

As i write the mapping si quite complex.... i try to explain....

i have the table PostiOccupatiPerDataEvento with 7 (i mean SEVEN) columns with foreing keys.... plus a column with identity PK

id_ConfigurazioneLocale
codice_ordine_posto
id_fila
codice_data_evento
codice_titolo
id_BigliettoAbbonamento
id_abbonamento

codice_titolo, id_BigliettoAbbonamento, id_abbonamento are mutually exclusive... i mean 2 of these 3 must be null and the other must be a valid value.. they are similar entity...


id_ConfigurazioneLocale and codice_ordine_posto are FK for OrdinePostoPerConfigurazioneLocali ... but are also used for other FK :(

@ManyToOne(cascade={},
fetch=FetchType.LAZY)

@JoinColumns( {
@JoinColumn(name="id_ConfigurazioneLocale", unique=false, nullable=true, insertable=true, updatable=true),
@JoinColumn(name="codice_ordine_posto", unique=false, nullable=true, insertable=true, updatable=true) } )
public OrdinePostoPerConfigurazioneLocali getOrdinePostoPerConfigurazioneLocali() {
return this.ordinePostoPerConfigurazioneLocali;

}

id_ConfigurazioneLocale, codice_ordine_posto, id_fila, codice_data_evento are FK for FilePerOrdinePostoPerDataEvento

@ManyToOne(cascade={},
fetch=FetchType.LAZY)

@JoinColumns( {
@JoinColumn(name="id_ConfigurazioneLocale", unique=false, nullable=true, insertable=false, updatable=false),
@JoinColumn(name="codice_ordine_posto", unique=false, nullable=true, insertable=false, updatable=false),
@JoinColumn(name="id_fila", unique=false, nullable=true, insertable=false, updatable=false),
@JoinColumn(name="codice_data_evento", unique=false, nullable=true, insertable=false, updatable=false) } )
public FilePerOrdinePostoPerDataEvento getFilePerOrdinePostoPerDataEvento() {
return this.filePerOrdinePostoPerDataEvento;

}

codice_data_evento is the FK to DataEvento

@ManyToOne(cascade={},
fetch=FetchType.LAZY)

@JoinColumn(name="codice_data_evento", unique=false, nullable=true, insertable=false, updatable=false)
public DataEvento getDataEvento() {
return this.dataEvento;

}

i get this error with this simple EJbQuery:
String ejbQuery = "select distinct entity from DataEvento as entity "
+ "left outer join fetch entity.postiOccupatiPerDataEventos "
+ "where entity.codice = :codice ";

i checked the db data.... it's correct.. i try in sql manager.. and the query works.. i mean it fetch a dataEvento with the only postiOccupatiPerDataEvento present... but then hibernate try to convert to bigint an alfanumeric column!?!?!??!
Thanks in advice.....


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

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.