![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
on stackoverflow
// Defining tables and a schema: import org.squeryl.PrimitiveTypeMode._ class Author(var id: Long, var firstName: String, var lastName: String) class Book(var id: Long, var title: String, @Column("AUTHOR_ID") // the default 'exact match' policy can be overriden var authorId: Long, var coAuthorId: Option[Long]) { def this() = this(0,"",0,Some(0L)) } object Library extends Schema { //When the table name doesn't match the class name, it is specified here : val authors = table[Author]("AUTHORS") val books = table[Book] } // Basic usage Class.forName("org.postgresql.Driver"); val session = Session.create( java.sql.DriverManager.getConnection("jdbc:postgresql://localhost:5432/squeryl", "squeryl", "squeryl"), new PostgreSqlAdapter ) //Squeryl database interaction must be done with a using block : import Library._ using(session) { books.insert(new Author(1, "Michel","Folco")) val a = from(authors)(a=> where(a.lastName === "Folco") select(a)) }
no subject
Date: 2010-02-24 05:35 am (UTC)no subject
Date: 2010-02-24 10:27 am (UTC)