JPA Hibernate @Version annotations and BOOL/TinyInt(1) => boolean mapping
Just starting out with JPA using Hibernate, and I'm able to autogenerate my persistence.xml file and related Object classes from my MySQL DB. But there are a couple of "fix-ups" I seem to have to do after-the-fact that are a bit tedious and I was hoping to find a way to configure them as the defaults.
First, columns in my MySQL table that are BOOL (well, I guess technically TinyInt(1)) end up mapping to byte by default. I can go through each one and change it to boolean from the Import Database Schema dialog window, but it's a bit of a pain to have to do this for each one. Is there a way to change the default mapping?
Second, I'm using optimistic locking with a version field. If I go in and add the @Version annotation to the generate classes, everything works great. But I'd rather not have to do that after they're generated. Is there a way to get the generated classes to add them automatically?
Thanks,
Doug
Please sign in to leave a comment.
Hello Douglas,
>Is there a way to change the default mapping?
It is not possible now. Please vote for these requests: https://youtrack.jetbrains.com/issue/IDEA-144763 , https://youtrack.jetbrains.com/issue/IDEA-135379
>If I go in and add the @Version annotation to the generate classes, everything works great. But I'd rather not have to do that after they're generated. Is there a way to get the generated classes to add them automatically?
There is no special handling for @Version annotation or ability to customize it. See also related https://youtrack.jetbrains.com/issue/IDEA-76638
Please feel free to comment on these requests about your use case. Thanks.