-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Which property can be put in persistence.xml
PostPosted: Fri Mar 28, 2008 6:32 am 
Newbie

Joined: Fri Mar 28, 2008 5:48 am
Posts: 5
Hibernate version: hibernate-3.2.5.ga

Mapping documents: persistence.xml

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: Derby (last version)

The generated SQL (show_sql=true): nothing



Hi all,
Just one simple question but I've been searchin' n googlin' for hours ...

I'm in a full jee5 (ie EJB3 and JPA)
I use hibernate-3.2.5.ga and just simply want to generate an schema.ddl

Is this just impossible ? if not why isn't it in the manual or documentation

By the way I didn't found any page on the site listing all the properties that could be put in a persistence.xml.
Is that normal ?

Ok i'm quite new to hibernate but I have really tried to found this by myself (even tried some <property name="hibernate.hbm2ddl.output or export etc... but nothing !)
Just a clear listing of which property can be put in persistence.xml will be cool for everybody, I think

thanks


Top
 Profile  
 
 Post subject: Re: Which property can be put in persistence.xml
PostPosted: Fri Mar 28, 2008 2:42 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
I might not be right person to answer this since I never used the schema exported but I can tell you the reason probably you are not able to find how to do that in persistence.xml is that it does not make any sense to do it in persistence.xml. That is, persistence.xml is a runtime matter and who wants to create a ddl file at runtime? I am suggesting you should look for an ant task or something similar. On the other hand, you can instruct hibernate to create, update or just verify database schema with what it has. That would a runtime matter. For list of properties look at the hibernate core documentation section 3.4. Optional configuration properties. There are also other properties that are scattered throughout the document.



Farzad-


Top
 Profile  
 
 Post subject: Schema Generation
PostPosted: Fri Mar 28, 2008 4:35 pm 
Newbie

Joined: Fri Mar 21, 2008 2:20 pm
Posts: 10
Location: London
Hi laurent4x,

To generate a schema.ddl file use org.hibernate.tool.ant.HibernateToolTask and hbm2ddl.

Personally I use an ant task to do this, my task looks like this -

Code:
    <taskdef name="hibernatetool"
         classname="org.hibernate.tool.ant.HibernateToolTask"/>

    <!-- Create SQL DDL statements and writes them to a file -->
    <target name="exportSchemaToFile">
       
        <hibernatetool destdir="${build.dir}">

            <!--// Note : don't have to name the persistence unit
            // if only one persistence.xml on the path -->
            <jpaconfiguration persistenceunit="xxxapp"/>

            <classpath>
                <!-- In this classpath you put your classes dir,
                and/or jpa persistence jar -->
                <path location="${build.classes.dir}"/>
            </classpath>

            <hbm2ddl export="false" outputfilename="sql/schema.ddl"/>

        </hibernatetool>

    </target>


There is documentation on this website for hbm2ddl (somewhere).

Forget about persistence.xml in this case - this file isn't anything to do with schema generation.

However, in case you still need to know what can go in this file, the XML schema is specified in the EJB 3.0 specification (in the persistence part) available from jcp.org.

Andy.

_________________
http:// www.techfoundry.com


Top
 Profile  
 
 Post subject: Okay !
PostPosted: Fri Mar 28, 2008 5:01 pm 
Newbie

Joined: Fri Mar 28, 2008 5:48 am
Posts: 5
I will like to thank you !
I was wrong in the way I was thinking :
In fact I used to work with netbeans, glassfish and toplink.
in that configuration toplink was convenient because in dev. time I just ask to generate the ddl on every run via the persistence.xml .
And when I switch to prod I change the persistence.xml

It was just convenient (just one place to modify) and I wrongly assumed this was a "normal" way to handle this.

But I understand what you explained me and in fact it makes sense !

Hope this will help others .

I will give this a try on Monday!
Cheers


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.