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>

Shubham Kadlag
  • 2,248
  • 1
  • 13
  • 32
RMagen
  • 612
  • 2
  • 9
  • 23

3 Answers3

19

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 !!

RMagen
  • 612
  • 2
  • 9
  • 23
  • 7
    why doesn't work in 5.3 and 5.4 versions of hibernate? – Herman Zun Jun 07 '19 at 21:43
  • I'm using Spring Boot, that comes with Hibernate 5.3, can I downgrade to 5.2 ? how? Best Regards – Nicolas400 Oct 08 '19 at 17:57
  • I read that Annotation could be created with right click on source (https://docs.jboss.org/tools/4.0.0.Final/en/hibernatetools/html_single/index.html#map_config_editor #4.11) – Nicolas400 Oct 08 '19 at 18:15
  • 1
    @Nicolas400 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.+ – bodtx Feb 27 '20 at 09:49
  • 2
    @bodtx 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 version – RMagen Feb 28 '20 at 22:06
  • 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? – Doo Dah May 14 '20 at 15:26
3

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)

Rezak_tizi
  • 39
  • 1
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

oury.ba
  • 76
  • 5