-
1. Re: Entity from multiple tables
thejavafreak Aug 30, 2008 4:45 PM (in response to microcz)You need to join / relate the property in one object using either @ManyToMany, @OneToOne, @OneToMany, or @ManyToOne as such:
@Entity @Table(name="product") public class Product{ @ManyToOne private Category category; }
@Entity @Table(name="category") public class Category{ @OneToMany private List<Product> products; }
Is this what you're looking for?
-
2. Re: Entity from multiple tables
microcz Aug 30, 2008 5:19 PM (in response to microcz)thank you very much for your reply, but not at all... i want to make more complicated select.. in my app, i have these tables:
license
licensepkid
serialnumber
otherdatacomputer
licensepkid
otherdata
medium
mediumpkid
otherdatalicenseassignment
assignpkid
assigndate
licensefkid
computerfkidmediuminstallation
installpkid
installdate
mediumfkid
computerfkidreturnedlicense (cant be used)
returnpkid
licensefkid
I used seam to generate entities for all these tables ...those with fkids are joined automatically ...but what i wanna do is select all licenses (their serial numbers, date of assignment, medium on which they are) that has been installed but not returned ...so i wanna join licenseassignment with mediuminstallation on computerfkid somehow ...but i dunno what to do with resultlist is it possible to create entity bean for result of this query? -
3. Re: Entity from multiple tables
microcz Aug 30, 2008 5:25 PM (in response to microcz)oh ...sorry ... posting again without formatting
thank you very much for your reply, but not at all... i want to make more complicated select.. in my app, i have these tables:
license
license_pk_id
serial_number
other_data
computer
license_pk_id
other_data
medium
medium_pk_id
other_data
license_assignment
assign_pk_id
assign_date
license_fk_id
computer_fk_id
medium_installation
install_pk_id
install_date
medium_fk_id
computer_fk_id
returnedlicense (cant be used)
return_pk_id
license_fk_id
I used seam to generate entities for all these tables ...those with fk_ids are joined automatically ...but what i wanna do is select all licenses (their serial numbers, date of assignment, medium on which they are) that has been installed but not returned ...so i wanna join license_assignment with medium_installation on computer_fk_id somehow ...but i dunno what to do with resultlist is it possible to create entity bean for result of this query? -
4. Re: Entity from multiple tables
perwik Sep 8, 2008 1:08 AM (in response to microcz)How about creating a view of the query in the database and mapping your Entity to that view?