Not sure exactly what you mean, but I dont think that is what I am looking for.
I cannot even do what I envision to be very basic queries.
I have tried:
select account from Account as account, LoginDetails as loginDetails where account.id = loginDetails.accountId and loginDetails.username = :username
This only extracts the Account, and not the children (LoginDetails and UserDetails).
I have tried:
from Account as account where account.loginDetails.username = :username
This tries to do a join with account.id = loginDetails.id which will not bring back any results because they are not related by their ids. LoginDetails maps to account by its accountId.
I have been at this for 15 hours now today and I am getting absolutely nowhere. Any help on this would be greatly apreciated. :(
My mappings are now.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="cakeinabox.wrappers.Account" table="Account">
<cache usage="read-only"/>
<id name="id" column="id">
<generator class="sequence">
<param name="sequence">hibernate_sequence</param>
</generator>
</id>
<property name="credit" />
<property name="discount" />
<property name="openedDate" />
<property name="closedDate" />
<one-to-one name="loginDetails" class="cakeinabox.wrappers.LoginDetails" cascade="all" lazy="false" />
<one-to-one name="userDetails" class="cakeinabox.wrappers.UserDetails" cascade="all" lazy="false"/>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="cakeinabox.wrappers.LoginDetails" table="LoginDetails">
<cache usage="read-only"/>
<id name="id" column="id">
<generator class="sequence">
<param name="sequence">hibernate_sequence</param>
</generator>
</id>
<property name="username" />
<property name="password" />
<property name="accountId" update="false" insert="false" />
<many-to-one name="account" class="cakeinabox.wrappers.Account" cascade="all" column="accountId" lazy="false" />
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="cakeinabox.wrappers.UserDetails" table="UserDetails">
<cache usage="read-only"/>
<id name="id" column="id">
<generator class="sequence">
<param name="sequence">hibernate_sequence</param>
</generator>
</id>
<property name="firstName" />
<property name="lastName" />
<property name="addressLine1" />
<property name="addressLine2" />
<property name="city" />
<property name="county" />
<property name="telephoneNumber" />
<property name="emailAddress" />
<property name="postCode" />
<property name="country" />
<property name="accountId" update="false" insert="false" />
<many-to-one name="account" class="cakeinabox.wrappers.Account" cascade="all" column="accountId" lazy="false" />
</class>
</hibernate-mapping>