I'm having this issue and I can't figure out how to fix it. I hope this post helps.
NOTE: the same statement works fine with MySQL.
For the example i'm giving here i will show what i think is relevant for getting the picture of the problem, so if you find something is missing is probable that it was my decision just to keep the example clear.
Environment:
-Hibernate 2.1.4
-Sybase 12.5.1 Developer's Edition
-JConnector 2 (jar named jconn2.jar)
Context: I need to use one column as a PK and a FK, but Sybase complains because the same column appears twice in the SQL statement generated by Hibernate.
Here are the classes:
public class A {
String id = null;
B b = null;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public B getB() {
return b;
}
public B setB(B b) {
this.b = b;
}
}
/******************/
public class B {
String id = null;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
...and mappings follow:
<hibernate-mapping>
<class
name="A"
table="A"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
type="java.lang.String"
access="property"
column="code">
<generator class="native"/>
</id>
<many-to-one name="b"
class="B"
update="false"
insert="false"
column="code"/>
</class>
</hibernate-mapping>
/**************************/
<hibernate-mapping>
<class
name="B"
table="B"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
type="java.lang.String"
access="property"
column="code">
<generator class="native"/>
</id>
</class>
</hibernate-mapping>
GENERATED SQL STATEMENT:
Hibernate: select a0_.code as code1_, a0_.code as code1_, from A a0_
ERROR:
(util.JDBCExceptionReporter 38 ) SQL Error: 7348, SQLState: ZZZZZ
(util.JDBCExceptionReporter 46 ) Select expression results in more than one column having same name. Column name 'code1_' is specified more than once
Well, if someone understands what's happening i would appreciate some help.
Thanks in advance.
|