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.  [ 1 post ] 
Author Message
 Post subject: [ann] Hibernate ORM and HQL Scripting
PostPosted: Mon Jan 31, 2005 1:13 pm 
Newbie

Joined: Sun Jan 30, 2005 10:24 pm
Posts: 1
Hello,

I'd like to introduce Hibernate scripting, a new feature in the JudoScript language, and hope to get some feedback from active Hibernate developers.

The crux of Hibernate scripting in JudoScript is demonstrated as follows:

8< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
import com.foo.bar.*;

// Initialize Hibernate:
hib::setup (
hibernate.connection.url = 'jdbc:mysql://localhost/test',
hibernate.connection.username = 'user',
hibernate.connection.password = 'pass',
hibernate.hbm2ddl.auto = 'update',
judoscript.echo = true
)

// the classes in the object model (under com.foo.bar)
Foo,
Bar
;

// Create a few new objects and save them:
for i from 0 to 10 {
x = new java::Foo;
x.prop1 = 'abc';
println 'Before save: x.id = ', x.id;
hib::save(x);
println 'After save: x.id = ', x.id;
}

// HQL Query:
hib::query qry: // or hib::iterate
from Foo f
where f.id > 1 and f.id < 10
;
for x in qry { // qry holds a list of Foo's.
println x;
}

// HQL Delete; with bind variables:
hib::delete:
from Foo f
where f.id > :startIdx and f.id < :endIdx
; with startIdx:Long = 3, endIdx:Long = 5;

// Done.
hib::close; // (closes the per-thread Session instance)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >8

Note, this program works with both Hibernate2 and Hibernate3.

For more details, see:
http://www.judoscript.com/books/judoscr ... s/hib.html

Also, heavily related topics are Java scripting and JDBC scripting:
http://www.judoscript.com/books/judoscr ... /java.html
http://www.judoscript.com/books/judoscr ... /jdbc.html

Again, feedback will be much appreciated! (feedback link is on the website.)


Thanks,

James Huang,
author of JudoScript


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

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.