Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Scala and Hibernate examples, anyone?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  15 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Campbell  
View profile  
(2 users)  More options Dec 19 2007, 7:13 am
From: "Michael Campbell" <michael.campb...@gmail.com>
Date: Wed, 19 Dec 2007 07:13:43 -0500
Local: Wed, Dec 19 2007 7:13 am
Subject: Scala and Hibernate examples, anyone?
Does anyone have any examples of how you're stitching together scala
and hibernate?   I'm looking for the most basic of basics; an example
scala domain class and how the hibernate mapping works with it, or
something at least at that level.

Thanks


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Pollak  
View profile  
 More options Dec 19 2007, 9:15 am
From: David Pollak <d...@athena.com>
Date: Wed, 19 Dec 2007 06:15:32 -0800
Local: Wed, Dec 19 2007 9:15 am
Subject: Re: [lift] Scala and Hibernate examples, anyone?

On Dec 19, 2007, at 4:13 AM, Michael Campbell wrote:

> Does anyone have any examples of how you're stitching together scala
> and hibernate?

I'd like to see this too... especially in the wiki!

>   I'm looking for the most basic of basics; an example
> scala domain class and how the hibernate mapping works with it, or
> something at least at that level.

> Thanks

--
David Pollak
http://blog.lostlake.org

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Viktor Klang  
View profile  
 More options Dec 19 2007, 9:42 am
From: "Viktor Klang" <viktor.kl...@gmail.com>
Date: Wed, 19 Dec 2007 15:42:48 +0100
Local: Wed, Dec 19 2007 9:42 am
Subject: Re: [lift] Re: Scala and Hibernate examples, anyone?

On 12/19/07, David Pollak <d...@athena.com> wrote:

> On Dec 19, 2007, at 4:13 AM, Michael Campbell wrote:

> > Does anyone have any examples of how you're stitching together scala
> > and hibernate?

> I'd like to see this too... especially in the wiki!

+1 for this! :)

(in my heart I hope for the Scala first class properties syntax to create a
very sexy JPA integration)

Cheers,
Viktor

--
_____________________________________
/                                                                 \
        /lift/ committer (www.liftweb.net)
      SGS member (Scala Group Sweden)
  SEJUG member (Swedish Java User Group)
            Coffee drinker (Skånerost)
\_____________________________________/

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
edgarchan  
View profile  
(1 user)  More options Dec 19 2007, 10:27 am
From: edgarchan <edgarchancarri...@gmail.com>
Date: Wed, 19 Dec 2007 07:27:56 -0800 (PST)
Local: Wed, Dec 19 2007 10:27 am
Subject: Re: Scala and Hibernate examples, anyone?
This is a simple and nice example:

http://technically.us/code/x/the-escape-hatch

On Dec 19, 6:13 am, "Michael Campbell" <michael.campb...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonas Bonér  
View profile  
 More options Jan 8 2008, 6:43 am
From: "Jonas Bonér" <jbo...@gmail.com>
Date: Tue, 8 Jan 2008 03:43:08 -0800 (PST)
Local: Tues, Jan 8 2008 6:43 am
Subject: Re: Scala and Hibernate examples, anyone?
Here is a writeup:
http://www.artima.com/forums/flat.jsp?forum=276&thread=222229

On Dec 19 2007, 4:27 pm, edgarchan <edgarchancarri...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Bendiola  
View profile  
 More options Jan 16 2008, 2:23 pm
From: Steve Bendiola <steve.bendi...@gmail.com>
Date: Wed, 16 Jan 2008 11:23:28 -0800 (PST)
Local: Wed, Jan 16 2008 2:23 pm
Subject: Re: Scala and Hibernate examples, anyone?
I found this mention of lift, but it makes it seem like you can't use
lift with hibernate.

http://jonasfagundes.com/blog/2008/01/grails-the-good-the-ugly-and-th...

On Dec 19 2007, 8:15 am, David Pollak <d...@athena.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Pollak  
View profile  
 More options Jan 16 2008, 2:40 pm
From: "David Pollak" <feeder.of.the.be...@gmail.com>
Date: Wed, 16 Jan 2008 11:40:38 -0800
Local: Wed, Jan 16 2008 2:40 pm
Subject: Re: [lift] Re: Scala and Hibernate examples, anyone?

On 1/16/08, Steve Bendiola <steve.bendi...@gmail.com> wrote:

> I found this mention of lift, but it makes it seem like you can't use
> lift with hibernate.

> http://jonasfagundes.com/blog/2008/01/grails-the-good-the-ugly-and-th...

THanks and I did a follow-up on his blog

On Dec 19 2007, 8:15 am, David Pollak <d...@athena.com> wrote:

--
lift, the secure, simple, powerful web framework http://liftweb.net
Collaborative Task Management http://much4.us

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
steve.yen  
View profile  
 More options Jan 24 2008, 10:27 pm
From: "steve.yen" <steve....@gmail.com>
Date: Thu, 24 Jan 2008 19:27:00 -0800 (PST)
Subject: Re: Scala and Hibernate examples, anyone?
Hi, I wrote up an single file example, here, of using Scala and
Hibernate...

http://scalabase.ning.com/profiles/blog/show?id=1808193%3ABlogPost%3A201

Cheers,
Steve


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fred Janon  
View profile  
 More options Jan 24 2008, 11:46 pm
From: "Fred Janon" <fja...@gmail.com>
Date: Fri, 25 Jan 2008 13:46:40 +0900
Local: Thurs, Jan 24 2008 11:46 pm
Subject: Re: [lift] Re: Scala and Hibernate examples, anyone?

Hi Steve,

I am Scala beginner, so sorry about the basic question...

I wonder why in withTxSession, you use:

    val r = f(s) // builds the function
    t.commit // commits the session
    r // executes the function

and not
 f(s) // executes the function with the session as a parameter
 t.commit // commits the session and save the obejcts created/updated in the
function

Also, I thought that hibernate .jar included all the other jars but I can't
check it at the moment.

Thanks

Fred

On Jan 25, 2008 12:27 PM, steve.yen <steve....@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
steve.yen  
View profile  
 More options Jan 25 2008, 12:56 am
From: "steve.yen" <steve....@gmail.com>
Date: Thu, 24 Jan 2008 21:56:22 -0800 (PST)
Local: Fri, Jan 25 2008 12:56 am
Subject: Re: Scala and Hibernate examples, anyone?

On Jan 24, 8:46 pm, "Fred Janon" <fja...@gmail.com> wrote:

> Hi Steve,

> I am Scala beginner, so sorry about the basic question...

> I wonder why in withTxSession, you use:

>     val r = f(s) // builds the function
>     t.commit // commits the session
>     r // executes the function

> and not
>  f(s) // executes the function with the session as a parameter
>  t.commit // commits the session and save the obejcts created/updated in the
> function

Hi Fred, I read it like this...

  val r = f(s) // calls the function or callback f, saving the result
in variable r
  t.commit // commits the transaction
  r // returns the result that came from f

> Also, I thought that hibernate .jar included all the other jars but I can't
> check it at the moment.

You might be right.  I didn't check that myself, but followed the
Hibernate tutorial and kept on adding jar files until the compiler
stopped complaining.  Real teeth gritting trying to parse a durn
simple XML string into a org.w3c.dom.Document!  dom4j?  sax?  meh.

Thanks,
Steve


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Green  
View profile  
 More options Jan 26 2008, 11:05 am
From: "Daniel Green" <october...@gmail.com>
Date: Sat, 26 Jan 2008 11:05:37 -0500
Local: Sat, Jan 26 2008 11:05 am
Subject: Re: [lift] Re: Scala and Hibernate examples, anyone?
My system for Hibernate+Scala was that persisted classes would have an
associated Actor DAO that they are tied to by a  trait. This gives
each instance of an object a "save" and "delete" function. The Actor
DAOs were written so that they inherited (and could override) CRUD
operations. It was a pretty nifty system. There was also a bunch of
utility functions to aid searching and common operations. It was quite
simple to setup new database objects. I also had an ant file that
controlled an empty rails project so I could use migrations and model
generation to help manage the SQL side and (if I wanted to go that
far) generate hibernate mappings. I've gotten permission to release
this stuff into the wild if you guys think it's worth exploring.

On Jan 25, 2008 12:56 AM, steve.yen <steve....@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jsm2prof  
View profile  
 More options Jan 26 2008, 12:55 pm
From: jsm2prof <jsm2p...@googlemail.com>
Date: Sat, 26 Jan 2008 09:55:10 -0800 (PST)
Local: Sat, Jan 26 2008 12:55 pm
Subject: Re: Scala and Hibernate examples, anyone?
Daniel Green,
I'm certainly eager to explore it.  But docs with include plenty of
context help me to not be confused.  The sample files you had
would be one of the most useful things for those who learn by
doing.
Johnnie

On Jan 26, 10:05 am, "Daniel Green" <october...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fred Janon  
View profile  
 More options Jan 27 2008, 2:33 am
From: "Fred Janon" <fja...@gmail.com>
Date: Sun, 27 Jan 2008 15:33:51 +0800
Local: Sun, Jan 27 2008 2:33 am
Subject: Re: [lift] Re: Scala and Hibernate examples, anyone?

Hi Daniel,

It would be great if you release it. I would love to look at it.

Thanks for sharing

Fred

On 1/27/08, Daniel Green <october...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Green  
View profile  
 More options Jan 27 2008, 6:49 pm
From: "Daniel Green" <october...@gmail.com>
Date: Sun, 27 Jan 2008 18:49:23 -0500
Local: Sun, Jan 27 2008 6:49 pm
Subject: Re: [lift] Re: Scala and Hibernate examples, anyone?
I rewrote allot of stuff and I haven't tested my rewrites yet (allot
of this was written in this email) but here's a general idea of the
stuff I was doing. Note that I assume that I can parametrize Class. I
did this here so I could unclutter my examples.

There was a base actor for all actors servicing a class:

abstract class ServiceActor[T](val servicedClass : Class[T]) extends Actor {
  override def act {
    loop {
      react {
        provide
      }
    }
  }

  def provide : PartialFunction[Any,Unit]
  def services(f : PartialFunction[Any,Unit]) = f

}

so if i wanted to implement CRUD operations I'd first write a convenience trait:

trait CRUDServices[T <: POSO] {
  val serviceActor : CRUDService[T]

  def delete(poso : T) = serviceActor !? Delete(poso)
  def get(id : int) : T = (serviceActor !? Get(id)).asInstanceOf[T]
  def save(poso : T) : int = (serviceActor !? Save(poso)).asInstanceOf[int]

}

and then I'd implement that actor:

class CRUDService[T <: POSO](servicedClass : Class[T]) extends
ServiceActor[T](servicedClass) with CRUDServices {
  override val serviceActor = this

  override def provide = services {
    case Save(poso) => reply {
      transact((s, t) => s.save(poso))
      poso.id
    }
    case Delete(poso) => reply(transact((s,t) => s.delete(poso)))
    case Get(id) => reply {
      transact { (s,t) =>
        val poso = s.load(servicedClass, id).asInstanceOf[T]
        Hibernate.initialize(poso)
        poso.id = id
        poso
      }
    }
  }

}

and now for... THE END RESULT!

If I just wanted an instance of a generic crud service to manage a
class I could:

val service = new CRUDService(classOf[User])
service.start
service.delete(user)

or if I needed to batch a mass delete of users and then move on to do
other stuff:

users.foreach(service ! Delete(_))

Or if I wanted to get fancy and implement some non-crud operations or
override crud operations:

// This will need to be started before it can be used
object UserService extends CRUDService(classOf[User]) {
  override def provide = services {
    case GetFriends(id) => reply(/*...*/)
    case Delete(poso) => reply(/* overrides generic delete */)
  } orElse super.provide

}

and that's all you need to do stuff like

UserService.delete(user)
// or
val user = UserService.get(id)

This is a really cool system and you can wire it to do some very fun
stuff. With Terracotta integration it is even better. In my POSO
(plain old scala object) trait I have tie ins to crud operations so I
can do stuff like

user.delete
// and
user.save

I've also written a bunch of hibernate utilities for searching,
paginating, etc.

On Jan 27, 2008 2:33 AM, Fred Janon <fja...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Viktor Klang  
View profile  
 More options Jan 27 2008, 7:17 pm
From: "Viktor Klang" <viktor.kl...@gmail.com>
Date: Mon, 28 Jan 2008 01:17:49 +0100
Local: Sun, Jan 27 2008 7:17 pm
Subject: Re: [lift] Re: Scala and Hibernate examples, anyone?

Would love to see your stuff man :)

-V

On Jan 28, 2008 12:49 AM, Daniel Green <october...@gmail.com> wrote:

--
_____________________________________
/                                                                 \
       /lift/ committer (www.liftweb.net)
     SGS member (Scala Group Sweden)
 SEJUG member (Swedish Java User Group)
\_____________________________________/

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google