Annotation not created when generating Hibernate mapping files
Asked Answered
T

4

5

I am following this link to generate hibernate file

https://www.mkyong.com/hibernate/how-to-generate-code-with-hibernate-tools/

the files are generated but without annotation. I checked the "generate EJB3 annotation " but still it is not working the DB is Postgres. I use to do it the same way and it was working fine.. few weeks ago I upgrade to eclipse to oxygen and change my workplace since then it is not working.. does any body know if there is a log file for the activity ? maybe I can find some thing there ?

this is my hibernate.cfg.xml file

    <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
    <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
    <property name="hibernate.connection.password">password</property>
    <property name="hibernate.connection.url">jdbc:postgresql://xxxxx/yyy</property>
    <property name="hibernate.connection.username">user</property>
    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <!-- <property name="hibernate.enable_lazy_load_no_trans">false</property> -->
    <property name="hibernate.search.autoregister_listeners">true</property>
    <property name="hibernate.validator.apply_to_ddl">false</property>
    <property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
    <property name="hibernate.enable_lazy_load_no_trans">true</property>


</session-factory>

Trituration answered 13/6, 2018 at 12:41 Comment(0)
T
20

After spending two days on it , I found the problem.. my hibernate version is 5.3 and still after changing the hibernate version to 5.2 (in the hibernate configuration window ) - it worked !!

Trituration answered 14/6, 2018 at 5:47 Comment(7)
why doesn't work in 5.3 and 5.4 versions of hibernate?Sustain
I'm using Spring Boot, that comes with Hibernate 5.3, can I downgrade to 5.2 ? how? Best RegardsMidsection
I read that Annotation could be created with right click on source (docs.jboss.org/tools/4.0.0.Final/en/hibernatetools/html_single/… #4.11)Midsection
@Midsection Generate your entities in a separate project with hibernate 5.2 as dependencie, then take the generated sources to your project where you will be able to use hibernate 5.+Pendant
@Pendant You dont need to do that,see in the question how to generate the entities using eclipse and then in the configuration window there is dropdown where you can change the hibernate versionTrituration
I know this post is a few years old. But nothing I am doing gives me annotations. I have tried checking the box for using "Java 5 syntax" and "Generate EJB3 annotations". I have also tried using Hibernate 5.2. Other ideas?Fop
for my jboss hibernate tool, in console configuration setting, no choice of 5.2, but before 5.4 is 4.3, anyway, after changing console configuration hibernate version to 4.3, then can generate annotation class, but is this a hibernate tool bug?Barabbas
C
4

After changing different possibilities in the configuration and connection, I changed the hibernate version from 5.3 to 5.2 and it works now ! (Tested on Photon and Oxygen versions of Eclipse)

Crest answered 22/8, 2018 at 16:29 Comment(0)
D
0

In my case I have to check the checkboxe "Generate EJB3 annotations" with hibernate version 5.2 to make it work fine !

enter image description here

Doityourself answered 13/7, 2020 at 9:14 Comment(0)
L
0

In hibernate Code Generation change the version to 4.3. In case you want to use a version greater than 4.3 change it later after generating classes.

Leatherwood answered 18/10, 2023 at 11:54 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Fairbanks

© 2022 - 2024 — McMap. All rights reserved.