I am working on an EJB 3 project where I need something where there is information related to a person. There are a lot of information like DOB, homepage, like, dislike etc. Now I want to retrieve a list of all users. But due to a lot of information, the page renders very slowly. So I want that when someone views a list of users, then only the first name and last name should be retrieved from the database. When someone sees the profile of the user, then only the full information of the user must be retrieved.
For this I thought that @Embedded should be great. But I didn't find much detail about embedded fields in any book. I thought that I would lazily load the embedded field. I don't know if that is possible or not. Also I am not sure how would the embedded field will be updated. So I am stuck now.
If embedded is not the solution, then I can go for one to one mapping. I can split the table into two also. So please suggest me the best way of solving this problem.
Also can I have 10 columns in the database and have two separate java classes which map to different columns of the same table using EJB 3. This may sound stupid as I don't know if this is possible or not.
Thanks Edvins. Well I have not tried this. This seems a good solution. But I don't know how to do this. Is it done by creating two entities and having less fields in one of the entities and all the fields in the other. If yes then how will I use queries with entity manager to manipulate the entity?? Can anyone give me a sample of how to do this or some internet tutorial...
Well I made it work. Thanks Edvins. The idea was enough for me to do it . I never thought about that. I was thinking about embedded objects and one to one mapping :XD: . Now the performance of my code has increased many folds.
It seems that you have found a way to map two classes to one table. Could you please share how you made it possible? I have a similar situation in my project. I also am using EJB3 and similar situation to yours.
Sorry Hitesh I saw this very late. But still if you need any help you can ask me. Debbie it seems you are right. One of the senior person scolded me for using this design saying that it is a bad design for future changes. I don't know what he meant by that but at least it works for now