Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

hibernate datasource relation

$
0
0
hi im new in smartgwt,im using Isomorphic SmartClient/SmartGWT Framework (v10.0p_2015-08-14/Pro Deployment 2015-08-14)

im trying relation in datasource but it won't works
i don't know what i did wrong can someone explain how to to this

account class:
public class Account implements Serializable {

protected long accoundID;
protected String accountUsername;
protected String accountPassword;
protected AccountDetails accountDetails;
//constructer
//getter,setter
}

accountDetails class:
public class AccountDetails implements Serializable {

protected long accountID;
protected String accountEmail;
protected String accountRegisteredDate;
protected Account account;
//constructer
//getter,setter
}

hibernate xml mapping for account class:
<hibernate-mapping>
<class name="jpac.main.server.serializable.Account" table="account" >
<id name="accountID" type="long">
<generator class="native"/>
</id>

<property name="accountUsername" type="string" />
<property name="accountPassword" type="string" />

<one-to-one name="accountDetails"
class="jpac.main.server.serializable.AccountDetails"
cascade="save-update">
</one-to-one>

</class>
</hibernate-mapping>

hibernate mapping for accountDetails class :
<hibernate-mapping>
<class name="jpac.main.server.serializable.AccountDetails" table="accountdetails" >
<id name="accountID" type="long">
<generator class="foreign">
<param name="property">account</param>
</generator>
</id>

<property name="accountEmail" type="string" />
<property name="accountRegisteredDate" type="date" />

<one-to-one name="account"
class="jpac.main.server.serializable.Account"
constrained="true">
</one-to-one>

</class>
</hibernate-mapping>


datasource for account:
<DataSource
ID="account"
serverType="hibernate"
tableName="account"
beanClassName="jpac.main.server.serializable.Account"
>
<fields>
<field name="accoundID" hidden="true" primaryKey="true" />
<field name="accountUsername" type="text" />
<field name="accountPassword" type="text" />
<field name="accountDetails" hidden="true" multiple="false"
type="accountDetails"
foreignKey="accountDetails.accountID"
/>
</fields>
</DataSource>

datsource for accountdetail:
<DataSource
ID="accountDetails"
serverType="hibernate"
tableName="accountDetails"
beanClassName="jpac.main.server.serializable.AccountDetails"
>
<fields>
<field name="accoundID" hidden="true" primaryKey="true" />
<field name="accountEmail" type="text" />
<field name="accountRegisteredDate" type="date" />
<field name="account" hidden="true" multiple="flase"
type="account"
foreignKey="account.accountID"
/>
</fields>
</DataSource>

console say:


.....
=== 2015-08-15 17:09:56,564 [65-0] WARN BasicDataSource - Related data source 'account' does not contain related field 'accountID' for field 'account'. Treating as simple field.
=== 2015-08-15 17:09:56,679 [65-0] ERROR DataSourceLoader - Exception while attempting to load a DataSource
org.hibernate.MappingException: An association from the table accountdetails refers to an unmapped class: jpac.main.server.serializable.Account
.....

....

=== 2015-08-15 17:09:56,681 [65-0] ERROR DataSourceLoader - BaseServlet Global Exception
javax.servlet.ServletException: DataSource 'account' failed to load due to an exception on the server:
An association from the table accountdetails refers to an unmapped class: jpac.main.server.serializable.Account
See the server-side log for additional details.
at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:268)
.....

Attached Files
File Type: java Account.java (987 Bytes)
File Type: xml Account.hbm.xml (673 Bytes)
File Type: java AccountDetails.java (966 Bytes)
File Type: xml AccountDetails.hbm.xml (736 Bytes)
File Type: xml account.ds.xml (529 Bytes)

Viewing all articles
Browse latest Browse all 4756