Lift offers several persistence mechanisms out of the box (Mapper, Record,
JPA and CouchDB currently), but these are just options. You are free to
handle your model in any way you want. There is no single forced mapping API
you have to code to.

Mapper itself is an ORM, it uses SQL under the hood, so you cannot use it
with Neo4j without a lot of work. Record is an API that is quite similar to
Mapper from the client's point of view, but that is designed to be data
store agnostic.

So if you want to use Neo4j in lift you have these options :
- find or write a Record implementation underlain by Neo4j;

- write your own mapping layer;

- code the model to the database directly
Neo4j being graph-based and embedded makes the third option far less painful
and   complex than with a SQL backend. There's no tricky relational/object
mismatch that needs to be worked around by an intermediate layer, so the
code will look quite natural. There's also no need for a Schemifier-like.

- use jo4neo. I stumbled upon this project yesterday and haven't used it,
but it looks like it should work with scala.

Christophe

PS: you should also add the following line in Boot.scala :
LiftRules.unloadHooks.prepend(() => Neo4j.db.shutdown)

On Mon, Mar 1, 2010 at 1:50 PM, Craig Taverner <cr...@amanzi.com> wrote:

> Hi Christophe,
>
> The code you sent seems great for wrapping each request in a transaction.
> But I still don't know how to get round lift's ORM or schemifier mechanism,
> or the mappers in mapper._
>
> Have you looked into that side of things? Or are no mappers required and
> you just code each model directly onto the database itself?
>
> Cheers, Craig
>
>
> On Mon, Mar 1, 2010 at 9:47 AM, Christophe Dehlinger <
> christophedehlin...@gmail.com> wrote:
>
>> HI Craig,
>>
>> For some reason, my response to your post was rejected by the list bot.
>> Here it is:
>>
>> ---------- Forwarded message ----------
>> From: Christophe Dehlinger <christophedehlin...@gmail.com>
>> Date: Mon, Mar 1, 2010 at 8:47 AM
>> Subject: Re: [Neo] Neo4j in Lift
>> To: Neo user discussions <user@lists.neo4j.org>
>>
>>
>> Hi Craig,
>>
>> I've been in the process of migrating my lift application from Mapper/h2
>> to neo4j for a few days. I haven't hit any snags yet, but on the other hand
>> my app is quite simple, with no ajax and comet stuff.
>>
>> Basically, add this:
>>
>> def withTx[A](code: => A): A = {
>>     val tx = db.beginTx
>>     try {
>>       val result = code
>>       tx.success
>>       result
>>     }
>>     finally {
>>       tx.finish
>>     }
>>   }
>>
>> and in Boot.scala:
>>
>> S.addAround(new LoanWrapper {
>>       override def apply[T](f: => T): T = withTx(f)
>>     })
>>
>> and you should be good to go for basic html stuff.
>>
>> I'm also writing a not-so-Record-like API for neo4j. Maybe I could publish
>> it if someone's interested. Not right now though, as it's still far too much
>> in flux and too tightly coupled to my app code.
>>
>> Cheers,
>> Christophe
>>
>>
>> On Mon, Mar 1, 2010 at 2:48 AM, Craig Taverner <cr...@amanzi.com> wrote:
>>
>>> Hi all,
>>>
>>> I've been looking at Martin Kleppman's Scala
>>> projects<http://wiki.neo4j.org/content/Scala>for neo4j to see if they
>>>
>>> can be used to help place neo4j behind a lift
>>> application, but I do not (yet) see any sign that these are for lift at
>>> all.
>>> I'm wondering if anyone knows how to get neo4j as the database for lift
>>> applications, and whether or not Martin's work is applicable to that
>>> scenario?
>>>
>>> Thanks, Craig
>>> _______________________________________________
>>> Neo mailing list
>>> User@lists.neo4j.org
>>> https://lists.neo4j.org/mailman/listinfo/user
>>>
>>
>>
>>
>
_______________________________________________
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to