1

I'm having a problem lately with adding mapping items to my hibernate.cfg.xml file. Just to be clear, It's not a mystery for me how to generate mapping anotations and all, but the process of adding these classes to hibernate.cfg.xml file just takes too long. For instance, "Hibernate Configuration 3.0 XML Editor" has a bult-in function to add mapping item in "Session Factory" tab. Sadly, you can add a class once on a time, which means going back to "Session Factory" tab, hitting "add" button in mapping section and choosing another class from the list.

Ex.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
 <session-factory name="">
  <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
  <property name="hibernate.connection.password">***********</property>   <-don't mind this
  <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/dvdrental</property>
  <property name="hibernate.connection.username">postgres</property>
  <mapping class="Model.Actor"/>  <- here's the problem. Can you generate this automatically?
 </session-factory>
</hibernate-configuration

>

Is there a more dynamic way to do this in eclipse? Couldn't "hibernate.cfg.xml" file be updated after I generated java files via "Hibernate Code Generation Configurations"? Am I missing something?

P.S. I'm not using Spring at the moment.

Radul
  • 11
  • 2
  • From [this answer](http://stackoverflow.com/a/1780362/3080094) `hibernate.archive.autodetection` might do the trick? – vanOekel May 17 '14 at 09:23

0 Answers0