one to many - what hibernate parameters should i use? -
i have table device has unique id of deviceid. have second table called deviceinfo primary key sequence deviceinfoseq info table has deviceid field foreign key pointing device. in device hbm have following deviceinfo
<?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 default-lazy="true" package="com.xxx.xxx.xxx"> <class name="device" table="device" dynamic-update="true"> <id name="dstring" column="deviceid" type="java.lang.string" unsaved-value="null" length="9"> <generator class="assigned"/> </id> .... <many-to-one name="deviceinfo" class="deviceinfo" outer-join="true" foreign-key="deviceid" > </many-to-one>
and device info hbm follows
<?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 default-lazy="true" package="com.xxx.xxx.xxx"> <class name="deviceinfo" table="deviceinfo" dynamic-update="true"> <id name="id" column="did" type="integer"> <generator class="native"> <param name="sequence">deviceinfoseq</param> </generator> </id> <property name="deviceid" column="deviceid" type="string" length="32"> </property> <property name="somefield" column="somefield" type="string" length="30" /> </class>
one device have 1 entry in deviceinfo table device need not have entry @ all. not devices have device info. if info present, have retrieve it. info updated source , hbm should if possible prevent updates. many-to-one correct? maybe should use one-to-many?
if use above hbm,
org.springframework.dao.invaliddataaccessresourceusageexception: not execute query; sql
Comments
Post a Comment