IDEA-8: JPA mapping for MySQL tables datatypes

For a new project, I enabled the JPA facet while defining the project and selected a datasource to map from. The database server  I use is MySQL 5.x. When I selected import database schema, IDEA correctly identified the tables from my selected datasource, however, the field mapping in the persistent classes is not to my liking. MySQL BIT fields get mapped to Java byte by default and VARCHAR fields get mapped to Java char[] . I would like BIT fields to get mapped to boolean and VARCHAR fields to get mapped to Java String types by default. I know that IDEA will let me me make these changes via a pulldown list, but I would like to use these mapping types by default every time. Submitting JPA-QL queries using char[] fields (or converting Strings to char[]) is messy.


I'm currently using Diana (build 9732) on an Ubuntu 8.04 laptop. JPA mapping screenshot is attached



Thanks very much.



Attachment(s):
IDEA_JPA_mapping.png
3 comments
Comment actions Permalink

I had the same problem for Oracle types. It has been fixed in since EAP #9757.

EDIT:
You might want to look at answer to this post:
http://www.jetbrains.net/devnet/message/5233964#5233964

0
Comment actions Permalink

Thank you for your response, Jan. I followed the thread that you suggested and agree with you about the JPA/Hibernate datatype mappings (the basis for my question). I also agree that Hibernate mapping files (.hbm.xml) files should be separate for each domain object. I will try getting a more recent IDEA 8.1.1 build, but my experience with non-official releases has not been very good (frequent stack traces or plugins that misbehave). IDEA-8 (build # 9732) which corresponds to the official 8.1 release (I believe) is very stable though.

0
Comment actions Permalink

Hello Viraf,

my experience with non-official releases has not been very good


 


Maybe something changed here a little bit, because I use build #9779 for a week now (every day's work), and did not experience any problems with it. I used #9757 a week earlier and it also ran fine. If you use a lot of database schema generation, I recommend using at least #9757, as there is fix for default database types (the problem you had).

0

Please sign in to leave a comment.