This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val validator = ModelValidatorBuilder(dao.entityType).get. | |
asInstanceOf[ModelValidatorBuilder[T]].initialize(bean) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SquerylController extends InterceptingController { | |
def around(request: Request, response: Response)(controller: (Request, Response) => Unit) = { | |
val session = SessionFactory.newSession | |
session.bindToCurrentThread | |
try{ | |
transaction{ | |
controller(request, response) | |
} | |
}finally{ | |
session.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//// SECTION TO SETUP CONNECTION POOLING & DB FOR SQUERYL | |
// Setup connection pooling for Squeryl with C3P0 | |
val cpds = new ComboPooledDataSource | |
cpds.setDriverClass("org.h2.Driver") | |
cpds.setJdbcUrl("jdbc:h2:mem:test") | |
cpds.setUser("sa") | |
cpds.setPassword("") | |
cpds.setMinPoolSize(5) | |
cpds.setAcquireIncrement(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.recursivity.jpa.Jpa._ | |
// gets an EntityManager for the default persistence-unit we set in the PersistenceUnit.unitName | |
val em = entityManager | |
//..or: | |
// to retrieved a specific named persistence-unit defined in your persistence.xml | |
val em = entityManager("someOtherPersistenceUnit") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lets register a StringValueTransformer for a Car domain object | |
val carDao = new JpaDao[Car, Long] | |
val transformer = new EntityTransformer[Car, Long](carDao) | |
TransformerRegistry.registerSingletonTransformer(carDao.entityType, transformer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ApplicationSchema is the Squeryl Schema object for the application | |
val peopleController = new CrudController[Person, Long](new SquerylController, | |
new LongKeyedDao[Person](ApplicationSchema.people), "people") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bowler with squeryl integration | |
val bowlerSqueryl = "org.bowlerframework" %% "squeryl-mapper" % "0.5.1" | |
// use an embedded H2 db and H2 JDBC driver | |
val h2database = "com.h2database" % "h2" % "1.2.144" | |
// use c3p0 for connection pooling | |
val c3p0 = "c3p0" % "c3p0" % "0.9.1.2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val bowlerJpa = "org.bowlerframework" %% "jpa-mapper" % "0.5.1" | |
// if you are using Hibernate as your JPA provider | |
val hibernateEntityManager = "org.hibernate" % "hibernate-entitymanager" % "3.6.1.Final" | |
// your JDBC provider | |
val hsqldb = "hsqldb" % "hsqldb" % "1.8.0.7" | |
//needs explicit defining if you use Hibernate as your JPA provider | |
val jbossRepo = "JBoss repo" at "https://repository.jboss.org/nexus/content/repositories/releases/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Setup: | |
sudo gem install rspec | |
sudo gem install cucumber | |
sudo gem install watir | |
sudo gem install firewatir | |
sudo gem install safariwatir | |
sudo gem install watir-webdriver | |
-- | |
Watir code: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// given the following case class: | |
case class Author(val id: Long, firstName: String, lastName: String, email: Option[String]){ | |
def this() = this(0,"John","Doe",Some("[email protected]")) | |
} | |
// when constructing the case class with: | |
val author = Author | |
// in the above case, Lift-JSON will arbitrarily render "{}" most of the time when doing: | |
compact(render(decompose(author)) |