-->
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: org.hibernate.QueryException: undefined alias
PostPosted: Mon Apr 06, 2009 5:53 am 
Newbie

Joined: Fri Jun 13, 2008 10:49 am
Posts: 3
Hi everyone,
I have used Hibernate with BEA Weblogic 3.1 and I have not had any problems.
Now I'm passing to BEA 4.0 and I'm starting to have some problems.

Using the same war file, with BEA 4.0 I have the following Exception:

org.hibernate.QueryException: undefined alias: TConfCodecPK [select TConfCodecPK.subtype FROM hibernate.classes.TConfCodec where confURI = 'sip:conf1239010359177@telecomitalia.it' and policy = 'allowed']

TConfCodec is the java class that maps the sql table, instead TConfCodecPK is the composite-id.

subtype is an element of composite-id TConfCodecPK. To read it from the table using BEA 3.1 I have had no problems, but now using BEA 4.0 I have it.
I don't know if I'm doing something wrong.
Please, help me

Here is described how they are composed

TConfCodec java class
public class TConfCodec {
private String media_label;
private String policy;
private String name;

private TConfCodecPK tConfCodecPK;

public TConfCodec() {
}

public TConfCodec(String confURI, String media_type,String media_label,String subtype,String policy,String name) {
this.name = name;
this.media_label = media_label;
this.policy = policy;

tConfCodecPK = new TConfCodecPK(confURI, media_type,subtype);
}


public String getMedia_label() {
return media_label;
}

public void setMedia_label(String media_label) {
this.media_label = media_label;
}


public String getPolicy() {
return policy;
}

public void setPolicy(String policy) {
this.policy = policy;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}


public TConfCodecPK getTConfCodecPK() {
return tConfCodecPK;
}

public void setTConfCodecPK(TConfCodecPK confCodecPK) {
tConfCodecPK = confCodecPK;
}

public String getConfURI() {
return this.tConfCodecPK.getConfURI();
}

public void setConfURI(String confURI) {
this.tConfCodecPK.setConfURI(confURI);
}

public String getMedia_type() {
return this.tConfCodecPK.getMedia_type();
}

public void setMedia_type(String media_type) {
this.tConfCodecPK.setMedia_type(media_type);
}

public String getSubtype() {
return this.tConfCodecPK.getSubtype();
}

public void setSubtype(String subtype) {
this.tConfCodecPK.setSubtype(subtype);
}
}


TConfcodecPK
public class TConfCodecPK implements Serializable {
private String confURI;
private String media_type;
private String subtype;

public TConfCodecPK()
{
}

public TConfCodecPK(String confURI, String media_type, String subtype)
{
this.confURI = confURI;
this.media_type = media_type;
this.subtype = subtype;
}

public String getConfURI()
{
return confURI;
}
public void setConfURI(String confURI)
{
this.confURI = confURI;
}
public String getMedia_type()
{
return media_type;
}
public void setMedia_type(String media_type)
{
this.media_type = media_type;
}
public String getSubtype()
{
return subtype;
}
public void setSubtype(String subtype)
{
this.subtype = subtype;
}
}

TConfCodec.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="hibernate.classes.TConfCodec" table="t_conf_codecs">
<composite-id name="TConfCodecPK"
class="hibernate.classes.TConfCodecPK">
<key-property name="confURI"/>
<key-property name="media_type"/>
<key-property name="subtype"/>
</composite-id>

<property name="media_label"/>
<property name="policy"/>
<property name="name"/>

</class>
</hibernate-mapping>


table t_conf_codecs
CREATE TABLE `t_conf_codecs` (
`confURI` varchar(100) NOT NULL,
`media_type` varchar(10) NOT NULL,
`media_label` varchar(15) NOT NULL,
`subtype` varchar(16) NOT NULL,
`policy` enum ('allowed','disallowed') NOT NULL DEFAULT 'allowed',
`name` varchar(10) NOT NULL,
/* Keys */
PRIMARY KEY (`confURI`, `media_type`, `subtype`)
)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 6:12 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Maybe it's a problem with case-sensitivity. In your class you didn't capitalize the pk-attribute ("tConfCodecPK").
Make sure that you allways use the right case, so you have to change your mapping to "<composite-id name="tConfCodecPK"..." and your query to "select tConfCodecPK.subtype FROM...".

_________________
-----------------
Need advanced help? http://www.viada.eu


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.