So, here's a basic object persistence example in 20 lines of Groovy:
import net.sourceforge.pbeans.data.*
import net.sourceforge.pbeans.*
dataSource = new GenericDataSource()
dataSource.setDriverClassName("com.mysql.jdbc.Driver")
dataSource.setUrl("jdbc:mysql://localhost/test?user=test&password=test")
store = new Store(dataSource)
class User implements Persistent {
Integer id
String name
Integer age
String hometown
}
joe = new User(name:"Joe User", age:43, hometown:"Bay Minette, AL")
store.insert(joe)
newjoe = store.selectSingle(User.class, "name", "Joe User")
assert newjoe.hometown == "Bay Minette, AL"
Link via TheServerSide.
Hmm and what about complex structures like:
ReplyDeleteA purchase order that HASA collection of
orderitems