-->
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: HQL interpretation problem - id
PostPosted: Mon Sep 05, 2005 9:59 pm 
Newbie

Joined: Mon Sep 05, 2005 9:51 pm
Posts: 3
hbm file like this :

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mappiong DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="IDBLEx" table="IDBLEx">
<id name = "ind" type="long" column="ind">
<generator class="native"/>
</id>

<property name = "id" type="string" not-null="true"/>
<property name = "ruleid" type="long" not-null="true"/>
<property name = "cpid" type="string" not-null="true"/>
<property name = "comment" type="string" not-null="true"/>
<property name = "date" type="calendar" not-null="true"/>
</class>
</hibernate-mapping>

and HQL like this :

"from IDBLEx ex where ex.id='john369'";

and generated SQL like this :

select idblex0_.ind as ind, idblex0_.id as id0_, idblex0_.ruleid as ruleid0_, idblex0_.cpid as cpid0_, idblex0_.comment as comment0_, idblex0_.date as date0_ from IDBLEx idblex0_ where idblex0_.ind='jonh369'

why id is translated into ind?

I'm using hibernate ver. 3.0.5.

thanks~


Top
 Profile  
 
 Post subject: POJO is...
PostPosted: Mon Sep 05, 2005 10:17 pm 
Newbie

Joined: Mon Sep 05, 2005 9:51 pm
Posts: 3
import java.io.Serializable;
import java.util.Calendar;
import org.apache.commons.lang.builder.ToStringBuilder;


/** @author Hibernate CodeGenerator */
public class IDBLEx implements Serializable {

/** identifier field */
private Long ind;

/** persistent field */
private Long ruleid;

/** persistent field */
private String id;

/** persistent field */
private String cpid;

/** persistent field */
private String comment;

/** persistent field */
private Calendar Date;

/** full constructor */
public IDBLEx(Long ruleid, String id, String cpid, String comment, Calendar date) {
this.ruleid = ruleid;
this.id = id;
this.cpid = cpid;
this.comment = comment;
Date = date;
}

/** default constructor */
public IDBLEx() {
}

public Long getInd() {
return this.ind;
}

public void setInd(Long ind) {
this.ind = ind;
}

public String getId() {
return this.id;
}

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

public String getCpid() {
return cpid;
}

public void setCpid(String cpid) {
this.cpid = cpid;
}

public Long getRuleid() {
return ruleid;
}

public void setRuleid(Long ruleid) {
this.ruleid = ruleid;
}

public String getComment() {
return this.comment;
}

public void setComment(String comment) {
this.comment = comment;
}

public Calendar getDate() {
return this.Date;
}

public void setDate(Calendar Date) {
this.Date = Date;
}

public String toString() {
return new ToStringBuilder(this)
.append("ind", getInd())
.append("ruleid", getRuleid())
.append("id", getId())
.append("cpid", getCpid())
.append("comment", getComment())
.append("date", getDate())
.toString();
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 05, 2005 10:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
'id' is a reserved word in HQL; it always referes to the entity's identifier (primary key).

Read the docs


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.