I will release soon actually.
Need some times with a decent connection.

Max Rydahl Andersen wrote:
emmanuel just released a version of hibernate annotations where the configuration is accessible - and as soon as I get around it (or someone else beats me to it by submitting
a patch) we will have a <ejb3configuration> in the ant tools...

/max

Hi,
Are there any plans for hibernate-tools to support EJB3 configurations?
Here is my horrible hack to get the generated schema.

   public static void generateDDL(String ddlFileName) throws
SecurityException,
            NoSuchFieldException, IllegalArgumentException,
IllegalAccessException {
        Ejb3Configuration cfg = new Ejb3Configuration();
HashMap<String, String> overridden = new HashMap<String, String>();
        overridden.put("hibernate.hbm2ddl.auto", "create-drop");
        // The following line actually drops and creates the DB schema.
        // If only JBoss would refactor the code better.
        EntityManagerFactory emf =
cfg.createEntityManagerFactory("edesk-test",
                overridden);

// Now go rummaging in emf's underpants (looking for privates - of
course)
        Field sessionFactoryField =
emf.getClass().getDeclaredField("sessionFactory");
        sessionFactoryField.setAccessible(true);
        SessionFactoryImpl sfi = (SessionFactoryImpl)
sessionFactoryField.get(emf);
        Field schemaExportField =
sfi.getClass().getDeclaredField("schemaExport");
        schemaExportField.setAccessible(true);
        SchemaExport schemaExport = (SchemaExport)
schemaExportField.get(sfi);

        // Now we have the SchemaExport, so we can generate the DDL now.
        schemaExport.setOutputFile(ddlFileName);
        schemaExport.setFormat(true);
        schemaExport.setDelimiter(";");
        schemaExport.execute(false, false, false, true);
}

As you can see, I use reflection to rummage around in the internals. There
must be a better way to do this, but it involves refactoring the
EJB3Configuration class.

Ciao,
Jonathan O'Connor
XCOM Dublin


*** XCOM AG Legal Disclaimer ***

Diese E-Mail einschliesslich ihrer Anhaenge ist vertraulich und ist allein
für den Gebrauch durch den vorgesehenen Empfaenger bestimmt. Dritten ist
das Lesen, Verteilen oder Weiterleiten dieser E-Mail untersagt. Wir bitten,
eine fehlgeleitete E-Mail unverzueglich vollstaendig zu loeschen und uns
eine Nachricht zukommen zu lassen.

This email may contain material that is confidential and for the sole use of the intended recipient. Any review, distribution by others or forwarding
without express permission is strictly prohibited. If you are not the
intended recipient, please contact the sender and delete all copies.

Hauptsitz: Bahnstrasse 33, D-47877 Willich, USt-IdNr.: DE 812 885 664
Kommunikation: Telefon +49 2154 9209-70, Telefax +49 2154 9209-900,
www.xcom.de
Handelsregister: Amtsgericht Krefeld, HRB 10340
Vorstand: Matthias Albrecht, Renate Becker-Grope, Marco Marty
Vorsitzender des Aufsichtsrates: Stephan Steuer



----
Max Rydahl Andersen
callto://max.rydahl.andersen

Hibernate
[EMAIL PROTECTED]
http://hibernate.org

JBoss Inc
[EMAIL PROTECTED]


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to