Hi--Here's the info, the question is down past the generated SQL
Hibernate version: 2.16
Mapping documents (2 in total):
Mapping doc 1:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
name="etest.model.Test"
table="TEST"
>
<id
name="id"
type="long"
column="TEST_ID"
>
<generator class="sequence">
<param name="sequence">test_seq</param>
</generator>
</id>
<property
name="datePublished"
type="java.sql.Timestamp"
column="DATE_PUBLISHED"
not-null="true"
length="7"
></property>
<property
name="name"
type="java.lang.String"
column="NAME"
not-null="true"
length="255"
></property>
<property
name="loaded"
type="java.lang.String"
column="LOADED"
not-null="true"
length="1"
></property>
<!-- associations -->
<!-- bi-directional many-to-one association to User -->
<many-to-one
name="Owner"
class="core.model.User"
not-null="true"
outer-join="true"
>
<column name="OWNER_ID" />
</many-to-one>
</class>
</hibernate-mapping>
Mapping doc 2:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
name="core.model.User"
table="mcd_portal.user_xmlapi_view_v1"
>
<cache usage="read-only"/>
<id
name="id"
type="long"
column="USER_ID"
unsaved-value="null"
>
<generator class="assigned" />
</id>
<property
name="firstName"
type="java.lang.String"
column="FIRST_NAME"
length="255"
></property>
<property
name="lastName"
type="java.lang.String"
column="LAST_NAME"
length="255"
></property>
</class>
</hibernate-mapping>
Name and version of the database you are using:
Oracle 9.2.0.5.0
The generated SQL (show_sql=true):
select this.TEST_ID as TEST_ID1_,
this.DATE_PUBLISHED as DATE_PUB2_1_,
this.NAME as NAME1_,
this.LOADED as LOADED1_,
this.OWNER_ID as OWNER_ID1_,
user1_.USER_ID as USER_ID0_,
user1_.FIRST_NAME as FIRST_NAME0_,
user1_.LAST_NAME as LAST_NAME0_
from TEST this
left outer join mcd_portal.user_xmlapi_view_v1 user1_
on this.OWNER_ID=user1_.USER_ID where 1=1
The above query never returns. It's really bad sql for what I need.
I am using a view from another schema to get the user ids. I know this is not standard, but should be doable.
I need sql like this:
select this.TEST_ID as TEST_ID1_,
this.DATE_PUBLISHED as DATE_PUB2_1_,
this.NAME as NAME1_,
this.LOADED as LOADED1_,
this.OWNER_ID as OWNER_ID1_,
user1_.USER_ID as USER_ID0_,
user1_.FIRST_NAME as FIRST_NAME0_,
user1_.LAST_NAME as LAST_NAME0_
from TEST this, mcd_portal.user_xmlapi_view_v1 user1_
WHERE this.OWNER_ID=1
and this.owner_id = user1_.user_id
What do I need to do to get this query, or something like it? Thanks for any help you provide!
|