Hello. I've got in my application a many to many relationship with two entities EstSocio, the Client-State (in Spanish) between two dates and Conv (which really represents the state of a service between two dates).
The DBMS is MySql. The composite keys are on both sides consisting of a Long id and a Date field of MySql.
The problems are:
1.-I have got the application working, but I want to change the design because I need to include some attributes in the join table. How can I access to the attributes of the join table between the two entities since I'm using the @JoinTable annotation and I have tried to make a HQL query using the name of the join table because I thought it would be automatically mapped by the annotations on both sides, but the JoinTable seems to not be mapped or detected when calling it by its name. So, the first problem is how to mend this. Do I have to change the design and make an object for the JoinTable or there is an easier solution???
2.- The second problem is independent from the previous one. The temporal key being a Date field in MySql gives some inconveniences. If a client updates his personal data twice on the same day, an Exception is thrown. I'd rather then change the Date field for a Timestamp, but the problem is that I don't know if I can retrieve the information and convert to a Date or Calendar easily with a format like dd/MM/yyyy or without a format depending on the situation. With this some sample code would be really appreciated.
Thank you very much, on advance.
|