Kostas Kougios | 6 Nov 2011 23:04

MapperDao ORM library 0.8.3 released

Hi all,

   I am happy to announce the release of v0.8.3 of the MapperDao ORM
library for Scala. The recent updates have seen the library to include
support for simple typed relationships (ie oneToMany Set[String]),
further mapping simplification, mock classes for all components of
mapperdao to facilitate mocking of the library and a circumflex web
example.

The library can be found at https://code.google.com/p/mapperdao/

The circumflex example is a web application for editing product
information along with their attributes, prices, categories and tags
and demonstrate the usage of many of the features of mapperdao like
relationships, CRUD Dao creation and pagination :
https://code.google.com/p/mapperdao-examples/  (productcatalogue)

Thanks,

Konstantinos Kougios

SImon Ochsenreither | 17 Nov 2011 00:13

[scala-announce] scalax-units – Units of Measurements for Scala

Hi everyone,

scalax-units – a combination of Jesper Nordenberg's metascala project and Erik Osheim's work on Numeric – provides typesafe computations with SI units and allows to write code like this:

  val mass: Mass[Double] = 4.0 kg
  val longMass: Mass[Long] = (4.0 kg) asLong
  val length: Length[Int] = (5 m) * 3
  val time: Time[Int] = 1 s
  val time2: Time[Int] = time + time
  val time3 = time2 + (1 minute)
  val temperature: Temperature[BigDecimal] = BigDecimal("22.22") k
  val speed: Speed[Int] = length / time
  val area: Area[Int] = length * length
  val volume: Volume[Int] = (23 m) * (1 m) * (1 m)
  val smallVolume = (volume asDouble) / 12.0
  val area2: Area[Int] = volume / (23 m)
  val accel: Acceleration[Double] = (10.0 m) / ((2.0 s) * (1.0 s))
  val accelNum: Double = accel toDouble

GitHub repo: https://github.com/soc/scalax-units
Binary download: https://github.com/downloads/soc/scalax-units/scalax-units_2.9.1-0.7.jar

I would be happy to get feedback. Let me know if you think this thing is useful!
Currently it is some horrible Frakenstein's-monster-like copy-and-paste of various files of two different projects and nothing official.
If there is enough interest I guess it would be possible to build something more refined out of it.

Have fun and let me know what you think!

Thanks,

Simon

Kostas Kougios | 22 Nov 2011 00:38

MapperDao ORM library 0.9.1 released

Hi all,

   Getting closer to v1.0, the mapperdao now supports sql server along
with oracle, mysql, derby, postgresql. MapperDao was build in scala
and compared to i.e. hibernate it supports immutability, options, map-
once and run on all supported databases without recompilation or any
code changes, configurable retrieval of entities during queries and no
need to impl equals() or hashCode just for mapperdao. Ofcourse
transactions are supported but best of all, a clean domain model
without code restrictions posed by other ORM tools. Finally, MapperDao
provides mixins to easily create CRUD dao's with options to retreive
paged rows of entities.

https://code.google.com/p/mapperdao/

Please provide feedback on the "Issues" section regarding i.e. which
database should be supported next or any feature that you might wish
to be added.

A quick example:

domain package:

class Person(val name: String, val company: Company)
class Company(val name: String)

dao package:

object PersonEntity extends Entity[IntId, Person](classOf[Person]) {
        val id = key("id") autogenerated (_.id)
        val name = column("name") to (_.name) // maps column "name" to
Person.name
        val company = manytoone(CompanyEntity) to (_.company)

        def constructor(implicit m: ValuesMap) = new Person(name,
company) with IntId with Persisted {
                val id: Int = PersonEntity.id
        }
}

object CompanyEntity extends Entity[IntId, Company](classOf[Company])
{
        val id = key("id") autogenerated (_.id)
        val name = column("name") to (_.name)

        def constructor(implicit m: ValuesMap) = new Company(name)
with IntId with Persisted {
                val id: Int = CompanyEntity.id
        }
}

now we can use mapperdao straight away to i.e. insert data:

val inserted=mapperDao.insert(PersonEntity,new Person("Kostas",new
Company("My Company"))
println(inserted.id)

or on a real life project we would use the mapperdao mixins to create
our dao's:

abstract class PersonDao extends TransactionalIntIdCRUD[Person] with
IntIdAll[Person] {
	val entity = PersonEntity

	// aliases
	val pe=PersonEntity
	val ce=CompanyEntity

	// find all Person working for a company. The return type is
List[Person with IntId]
	def workingForCompany(name:String) = queryDao.query(
		select from pe join (pe,pe.company,ce)
		where ce.name===name
}
// PersonDao mixes in the following methods: create(), retrieve(),
update(), delete() and also all():List[Person],
page(page,rowsPerPage):List[Person] etc

mvc package:

val person=personDao.create(new Person("Kostas",new Company("My
Company"))
println(person.id) // autogenerated

...

val people=personDao.page(1,20) // get's the 1st page containing 20
Person entities

MapperDao uses springframework's JdbcTemplate and transaction
infrastructure, featuring full support for transactional features of
each database, propagation and isolation levels along with transaction
timeouts.

Next versions might see optimizations, a pdf tutorial and a head to
head comparison with hibernate (performance, coding patterns, cross
database compatibility etc)

Best Regards,

Kostantinos Kougios


Gmane