-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hiber/JBoss: create tables
PostPosted: Fri Oct 17, 2003 4:40 am 
Beginner
Beginner

Joined: Fri Oct 17, 2003 4:11 am
Posts: 40
Hello,
i run Hibernate with JBoss (JMX) and it works.
Now i'm try to make a Stateless Session Bean that creates the tables from the hbm files for the server startup. Now there are some problems:
1) from within JBoss I can't get a Configuration (with
Code:
Configuration cfg=new Configuration.configure()
) without put an hibernate.cfg.xml in the "sar" directory. There is a way to don't use "hibernate.cfg.xml" and use the informations that are defined in the jboss-service.xml?!
2) who can i create tables?! i thinked with
Code:
cfg.generateSchemaCreationScript(...)
and then get a session, a connection and execute the query returned from generateSchemaCreationScript. It's right?!
3) there is a way to make some check like "there are data into the tables", etc. only using the hbm-files' informations? I'd like to create a SessionJB method "initDB" that check if some tables exist, if they have data and then (if it's needed) create them.

Thanx for any suggest
Giovanni


Top
 Profile  
 
 Post subject: configuration
PostPosted: Sun Oct 19, 2003 9:35 pm 
Newbie

Joined: Sun Oct 12, 2003 9:53 pm
Posts: 13
Location: Buenos Aires, Argentina
From the javadocs:
Quote:
Configuration configure(org.w3c.dom.Document document)
Use the mappings and properties specified in the given XML document.
protected Configuration configure(org.dom4j.Document doc)

Configuration configure(File configFile)
Use the mappings and properties specified in the given application file.
protected Configuration configure(InputStream stream, String resourceName)
Use the mappings and properties specified in the given application resource.
Configuration configure(String resource)
Use the mappings and properties specified in the given application resource.
Configuration configure(URL url)
Use the mappings and properties specified in the given document.


You could use any of this methods to have the config file almost anywhere and feed it hibernate as inputstream, url or so...

am I missing somthing? maybe I misunderstood the problem, sorry if I did.

Quote:
3) there is a way to make some check like "there are data into the tables", etc. only using the hbm-files'
I'm far from being an hibernate expert, but this sounds to me like a plain JDBC job, or maybe som hibernate functions could be used...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.