I have this a very basic problem and i am sure that there is a very simple solution to it.
I have two entities having many-to-many relationship at db level.
Customer
and Channel
joined by Customer_Channel
.
I am not a very pro at java persistence criteria and hibernate and this is part of a bigger application.
Now i have to bring this relationship in Customer. So should i model customer to have List<Channels> or List<Customer_Channels>
making it a Many-To-Many Relationship or One-To-Many relationship.
I don't need anything in Channel Entity.
Now i need to have a criteria query created to Fetch Customer belonging to a particular channel. A very simple SQL would be
Select Customer from Customer, Channel, Customer_Channel where Customer.ID=Customer_Channel.CustomerID and Customer_Channel.ChannelID=Channel.ID and Channel.ID = ?
or a very direct could be
Select Customer from Customer, Customer_Channel where Customer.ID=Customer_Channel.CustomerID and Customer_Channel.ChannelID=?
So which approach to take and what would be the Criteria Query in this case. My project doesn't use MetaModel classes.
Thanks a lot for help