sql - Hibernate one to one relation-ship mapping -


i made 1 one relation-ship between 2 tables shopping-card application, relation between customer , card,

create table `card` ( 'card_id' int not null, 'product_id` int not null, `customer_id` int unique , `product_quantity` int, primary key (`product_id`,`card_id`), key `fk_customer` (`customer_id`), constraint `fk_customer` foreign key (`customer_id`) references `customer`(`customer_id`), ) engine=innodb default charset=utf8;  create table `customer` ( `customer_id` int not null auto_increment, `email` varchar(100) default null, `name` varchar(100) default null, `password` varchar(100) default null, `photo` varchar(100) default null, `balance` double default null, primary key (`customer_id`), ) engine=innodb auto_increment=6 default charset=utf8; 

the problem when hibernate generate entities, customer.java follows:

public class customer implements java.io.serializable {  private integer customerid; private string email; private string name; private string password; private string photo; private double balance; private set cards = new hashset(0); } 

.hbm

<hibernate-mapping> <class name="customer" table="customer" catalog="shopping_card">     <id name="customerid" type="java.lang.integer">         <column name="customer_id" />         <generator class="identity" />     </id>     <property name="email" type="string">         <column name="email" length="100" />     </property>     <property name="name" type="string">         <column name="name" length="100" />     </property>     <property name="password" type="string">         <column name="password" length="100" />     </property>     <property name="photo" type="string">         <column name="photo" length="100" />     </property>     <property name="balance" type="java.lang.double">         <column name="balance" precision="22" scale="0" />     </property>     <set name="cards" table="card" inverse="true" lazy="true" fetch="select">         <key>             <column name="customer_id" not-null="true" unique="true" />         </key>         <one-to-many class="card" />     </set> </class> </hibernate-mapping> 

the 1 one relation translated 1 many, expect customer.java have card instance variable instead of set of cards, problem?


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -