java - What to provide datatype for List of objects for storing it in table column -
i trying create table user in database got stuck in providing datatype list of address should datatype used address column in sk_user table list adresses;
please find dto class-
package com.shopcart.dto; import java.util.list; public class user { private string name; private string email; private string mobile; private int age; list<address> adresses; public string getname() { return name; } public void setname(string name) { this.name = name; } public string getemail() { return email; } public void setemail(string email) { this.email = email; } public string getmobile() { return mobile; } public void setmobile(string mobile) { this.mobile = mobile; } public int getage() { return age; } public void setage(int age) { this.age = age; } public list<address> getadresses() { return adresses; } public void setadresses(list<address> adresses) { this.adresses = adresses; } @override public string tostring() { return "user [name=" + name + ", email=" + email + ", mobile=" + mobile + ", age=" + age + ", adresses=" + adresses + "]"; } }
yif want stome many address single user need create 1 more table address
in can use userid , address store addresses. create addressdto
for address table. , use list, store many object of addressdto
.
but need add id
column user table , dto class.
for ex:
package com.shopcart.dto; import java.util.list; public class addressdto{ private int userid; private string address; public string getaddress() { return address; } public void setaddress(string address) { this.address= address; } public int getuseride() { return userid; } public void setuserid(int userid) { this.userid= userid; } }
Comments
Post a Comment