-->
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.  [ 5 posts ] 
Author Message
 Post subject: problems with row name called "id"
PostPosted: Wed Oct 08, 2008 7:21 am 
Newbie

Joined: Wed Oct 08, 2008 6:41 am
Posts: 3
hi there!

first, sorry for my poor english.

i am working with MySQL 5 and Hibernate 3.2 with annotations.

i have one table like this:
DROP TABLE IF EXISTS regla_condicion;
create table regla_condicion(
id_regla_condicion int not null auto_increment primary key,
id_regla_facturacion int not null,
id_metadato int not null,
id int not null,
foreign key (id_regla_facturacion) REFERENCES regla_facturacion (id_regla_facturacion),
foreign key (id_metadato) REFERENCES metadato (id_metadato)
) ENGINE=INNODB;

and hibernate make me this pojo:
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;

/**
* ReglaCondicion generated by hbm2java
*/
@Entity
@Table(name = "regla_condicion", catalog = "iglabws")
public class ReglaCondicion implements java.io.Serializable {
private Integer idReglaCondicion;
private int idReglaFacturacion;
private int idMetadato;
private int id;

public ReglaCondicion() {
}

public ReglaCondicion(int idReglaFacturacion, int idMetadato, int id) {
this.idReglaFacturacion = idReglaFacturacion;
this.idMetadato = idMetadato;
this.id = id;
}

public ReglaCondicion(int idReglaFacturacion, int idMetadato, int id) {
this.idReglaFacturacion = idReglaFacturacion;
this.idMetadato = idMetadato;
this.id = id;
}

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id_regla_condicion", unique = true, nullable = false)
public Integer getIdReglaCondicion() {
return this.idReglaCondicion;
}

public void setIdReglaCondicion(Integer idReglaCondicion) {
this.idReglaCondicion = idReglaCondicion;
}

@Column(name = "id_regla_facturacion", nullable = false)
public int getIdReglaFacturacion() {
return this.idReglaFacturacion;
}

public void setIdReglaFacturacion(int idReglaFacturacion) {
this.idReglaFacturacion = idReglaFacturacion;
}

@Column(name = "id_metadato", nullable = false)
public int getIdMetadato() {
return this.idMetadato;
}

public void setIdMetadato(int idMetadato) {
this.idMetadato = idMetadato;
}

@Column(name = "id", nullable = false)
public int getId() {
return this.id;
}

public void setId(int id) {
this.id = id;
}
}

when i try to execute a query, hibernate says:
org.hibernate.ObctNotFoundException: No row with the given identifier exists: [com.ig.h.pojo.Replicacion#149]

i have written and read all the rows name and they are well. my table has a row name called "id". when i change this name, for example, id_p, it works fine. i can't change all my tables because there are a lot of apps using these tables.

i think there is a problem when there is a row name called "id".

can anydoby help me please?

thank you very much

QuiQue


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2008 9:13 am 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
Check this page:

http://www.hibernate.org/hib_docs/v3/reference/en-US/html/queryhql-identifier-property.html

Quote:
Note: this has changed significantly starting in version 3.2.2. In previous versions, id always referred to the identifier property no matter what its actual name. A ramification of that decision was that non-identifier properties named id could never be referenced in Hibernate queries.


You may have to use the latest hibernate version.

Christophe


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2008 9:15 am 
Beginner
Beginner

Joined: Tue Nov 27, 2007 9:44 am
Posts: 46
Hi,

the message says that there is no record (row) in the database where the identifying column (idReglaCondicion in your case) has the value you were looking for.

Regards,
Frank


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2008 9:22 am 
Beginner
Beginner

Joined: Tue Nov 27, 2007 9:44 am
Posts: 46
croudet wrote:
Quote:
Note: this has changed significantly starting in version 3.2.2. In previous versions, id always referred to the identifier property no matter what its actual name. A ramification of that decision was that non-identifier properties named id could never be referenced in Hibernate queries.


You may have to use the latest hibernate version.

Christophe


Thanks Christophe,

I wasn't aware of that fact. So my prior posting might be irrelevant to QuiQue' problem.

Frank


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2008 10:35 am 
Newbie

Joined: Wed Oct 08, 2008 6:41 am
Posts: 3
yeahhhhhhhhhhhhhhh

thank you very much Christophe!!

regards

QuiQue


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