[Lift] Re: Caching JPA entities and JPA vs Hibernate
You're probably on the right track, although I want to clarify: are the entity and its collections something that won't change often? Do you need transactional views on it (i.e. changes made by one session are immediately visible in others)? From your question about caching at Boot it sounds like this may be something that never changes or very infrequently. If it's something that never changes then you may be able to just load it in Boot, touch the collections (to force the lazy retrieval) and then you never need to deal with the cache per se anyways. As for the Hibernate annotations, the only one that's strictly needed to enable caching is @org.hibernate.annotations.Cache What annotations besides that one are you using, and which ones are causing conflicts? There are quite a few that overlap with the JPA standard annotation, so when I use them I usually make specific imports. There are several good articles out there on how to do this out on the web: http://www.gridshore.nl/2008/04/29/using-ehcache-and-verifying-that-it-works-with-jpa-and-springframework/ In particular, it's important to differentiate between the entity cache (enabled with the above annotation) and the query cache. It sounds like you need the former. Derek On Mon, Sep 15, 2008 at 4:20 PM, Tim Perrett [EMAIL PROTECTED] wrote: Hey guys, Thanks for your replies. I had a play around with the caching today and appeared to be getting a whole bunch of conflicts with org.hibernate.annotations, however these might be resolvable either by using limited imports to just scrape through with the annotations I need, or somehow do it with the orm.xml Im actually needed to cache an entity that has two collections of entities (and those collections have zero subsequent collections); I think a second level cache is appropriate but im not 100% on how to go about configuring it. Am I on the right path here? Effectively, the entity and the collections i want to cache are used on a request basis so i want to cache them in order to reduce database load so im working along the lines that the in memory cache will be an order of magnitude quicker to read from than the DB. Lift wise, where should i be looking to load the entities into the cache - from boot perhaps? Its also unclear how it actually does the cache (well, i know it stores the dehydrated object), but i mean its not like you actually have to manually tell the cache to load up the data so when does it actually do the cache itself? (and how can i validate its gone in there?) Cheers for any pointers Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Lift, Jetty and OneJar
Do you mean a JAR that you can just run, a la java -jar mywebapp.jar ? On Mon, Sep 15, 2008 at 5:25 PM, David Pollak [EMAIL PROTECTED] wrote: Folks, Has anyone built a Lift app that's deployable as a JAR file with Jetty as the container? Thanks, David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA Table annotation
Technically you can drop the constructor parens as well so it looks like @Table{val name=roles} Derek On Mon, Sep 15, 2008 at 5:08 PM, Tim Perrett [EMAIL PROTECTED] wrote: Chas, Change you annotation to this: @Table(){val name=roles} Scrap the xml attribute, then it will work no problems. This is the convention for using jpa annotations in scala. Doing this works perfectly for me. Cheers Tim Sent from my iPhone On 15 Sep 2008, at 23:43, Charles F. Munat [EMAIL PROTECTED] wrote: When I use the @Table annotation to set the table name for JPA, thus: @Entity @Table(name=ROLES) class Role It belches out that Table does not have the correct number of arguments. I tried just setting it in the orm.xml file, thus: entity class=Role table name=roles/ /entity And now I get a roles table, but also a role table. Any ideas what's going on here? The annotation syntax seems correct, but maybe this is a Scala issue? Chas. To stave off the inevitable question :-), the reason I want to do this is because I want a User class, but user is a reserved word in PostgreSQL. Also, I like plural table names better (even though that is not the classic RDBMS way). And I'd like the table naming to be consistent. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Lift, Jetty and OneJar
There is a maven plugin that allow to do it with winstone instead of jetty: http://alchim.sourceforge.net/winstone-maven-plugin/usage.html /davidB On Tue, Sep 16, 2008 at 2:08 PM, Derek Chen-Becker [EMAIL PROTECTED] wrote: Do you mean a JAR that you can just run, a la java -jar mywebapp.jar ? On Mon, Sep 15, 2008 at 5:25 PM, David Pollak [EMAIL PROTECTED] wrote: Folks, Has anyone built a Lift app that's deployable as a JAR file with Jetty as the container? Thanks, David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Caching JPA entities and JPA vs Hibernate
Hey Derek, You're probably on the right track, although I want to clarify: are the entity and its collections something that won't change often? Do you need transactional views on it (i.e. changes made by one session are immediately visible in others)? From your question about caching at Boot it sounds like this may be something that never changes or very infrequently. If it's something that never changes then you may be able to just load it in Boot, touch the collections (to force the lazy retrieval) and then you never need to deal with the cache per se anyways. Bang on - they will barley ever change. Certainly for this phase they wont change at all. Later I could build an admin control that flushes the cache (or refreshes it etc) I guess. I'll try this in boot and see what happens As for the Hibernate annotations, the only one that's strictly needed to enable caching is @org.hibernate.annotations.Cache What annotations besides that one are you using, and which ones are causing conflicts? There are quite a few that overlap with the JPA standard annotation, so when I use them I usually make specific imports. There are several good articles out there on how to do this out on the web: http://www.gridshore.nl/2008/04/29/using-ehcache-and-verifying-that-i... In particular, it's important to differentiate between the entity cache (enabled with the above annotation) and the query cache. It sounds like you need the former. Cheers Derek, I'll give it a whirl and let you know how I get on :) Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Lift - 1.0 (was: WebService example and versions of Lift)
I had a quick conversation with Derek over IM. We're in the process of putting together an outline and schedule for docs. I'll put together a new post as soon as I can (hoping tonight). On Sep 15, 4:44 pm, David Pollak [EMAIL PROTECTED] wrote: Derek, We'd love to have you help out. Perhaps Tyler can jump in here Thanks, David Derek Chen-Becker wrote: Amazing how far it's come since 0.1 last year. Once you and Marius are done cleaning things up maybe I can help with the Scaladocs a little. I know there's also quite a bit of catch-up on the Wiki to be done as well. In particular, updating the LiftTags, Cheat Sheet (maybe should be broken into chapters) and the howtos would be nice to make sure we're not duplicating things as well as providing coherent documentation for people who want to use it. As much as I love having a Wiki so that things can evolve quickly, I think it's important to have a polished set of core documentation that the rest of the Wiki can reference. Derek On Mon, Sep 15, 2008 at 2:27 PM, David Pollak [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Derek Chen-Becker wrote: So will that be a 1.0 or 0.10 release at that point? Just curious :) Once we get the API situation sorted out, we'll release 0.10. The next release will be RC1 about a month later. Then we'll go through RC cycles until we're happy with Lift, the ScalaDocs, the online documentation, the installer, etc. Derek On Mon, Sep 15, 2008 at 2:21 PM, David Pollak [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Mon, Sep 8, 2008 at 11:23 PM, Jorge Ortiz [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: The Lift APIs are undergoing some short-term trauma in expectation of long-term stability and backwards compatibility after the 1.0 release. The Lift APIs were fairly stable from 0.5-0.9. Marius and I have been going through and cleaning, scrubbing and polishing the APIs. Please expect them to stabilize by the end of October. Thanks, David On Mon, Sep 8, 2008 at 10:23 PM, Alan M [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Thanks a lot, that clears things up considerably. Now my only concern is how much stuff has changed so quickly.. But such is life on the edge eh? As for the other stuff, that probably belongs in another thread.. my bad in mixing.. Alan On Sep 5, 2:51 pm, David Pollak [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Fri, Sep 5, 2008 at 2:23 PM, Alan M [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: As far as I can tell the example doesn't compile with any version of Lift. ResponseIt is gone in .10 and SimpleController exists only in . 10. ResponseIt is now LiftResponse Here's a pretty simple set of REST services: object RestAPI extends XMLApiHelper { val logger: Logger = Logger.getLogger(us.esme.api) def dispatch: LiftRules.DispatchPf = { case RequestState(api :: get_msgs :: Nil, , GetRequest) = getMsgs } def getMsgs(): LiftResponse = { val r: Can[NodeSeq] = for (user - calcUser ?~ User not found; val lst = Mailbox.mostRecentMessagesFor(user.id http://user.id, 40)) yield lst.flatMap{ case (msg, why) = msg.toXml % why.attr} r } } So I'm trying to create a basic web service based on the example, any advice on how to proceed? What is the replacement for ResponseIt or what should I use instead of SimpleController? To be honest I'm having a hell of a time so far. It seems that Lift is very much tailored towards standard webapps with templated pages and O/R mapped data from databases, etc... Lift does REST and web services in a very simple way. It's simpler than any framework I've used. Lift also does standard XHTML, Ajax, and Comet in very simple, manageable ways. But in my case, I'm getting my data from other sources and in particular I'm getting my user authentication and authorization
[Lift] Re: Caching JPA entities and JPA vs Hibernate
Cool. For now I'd say just load it once, although you might want to make your own object to manage it. You could easily make it a lazy var for now and turn it into a synchronized def later if you need flush behavior. Derek On Tue, Sep 16, 2008 at 6:59 AM, Tim Perrett [EMAIL PROTECTED] wrote: Hey Derek, You're probably on the right track, although I want to clarify: are the entity and its collections something that won't change often? Do you need transactional views on it (i.e. changes made by one session are immediately visible in others)? From your question about caching at Boot it sounds like this may be something that never changes or very infrequently. If it's something that never changes then you may be able to just load it in Boot, touch the collections (to force the lazy retrieval) and then you never need to deal with the cache per se anyways. Bang on - they will barley ever change. Certainly for this phase they wont change at all. Later I could build an admin control that flushes the cache (or refreshes it etc) I guess. I'll try this in boot and see what happens As for the Hibernate annotations, the only one that's strictly needed to enable caching is @org.hibernate.annotations.Cache What annotations besides that one are you using, and which ones are causing conflicts? There are quite a few that overlap with the JPA standard annotation, so when I use them I usually make specific imports. There are several good articles out there on how to do this out on the web: http://www.gridshore.nl/2008/04/29/using-ehcache-and-verifying-that-i... In particular, it's important to differentiate between the entity cache (enabled with the above annotation) and the query cache. It sounds like you need the former. Cheers Derek, I'll give it a whirl and let you know how I get on :) Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Custom snippet attributes
Hey guys, If you have a call like: lift:mysnippet form=post is translated to form method=post action=blah however, is there a way to set the id attribute on that node? Simply adding the id in the markup is removed by lifts processing, so thats no good as most javascript / css things either need id or class to select the appropriate element. As im on a tight timeline with something, I just hacked the code to make it work with the id attribute (i know thats bad!) - we need a better solution really, and one that can accommodate any custom user attributes. Currently, the lift head looks like: def checkAttr(attr_name: String, in: MetaData): MetaData = in.filter(_.key == attr_name).toList match { case Nil = Null case x = new UnprefixedAttribute(attr_name, Text(x.first.value.text), Null) } attrs.get(form).map(ft = ( (form action={S.uri} method={ft.text}{ret}/form % checkMultiPart(attrs)) % checkAttr(class, attrs)) % checkAttr(id,attrs) ) getOrElse ret attrs.get(form).map(ft = form action={S.uri} method={ft.text}{ret}/form % checkMultiPart(attrs)) getOrElse ret } def checkMultiPart(in: MetaData): MetaData = in.filter(_.key == multipart).toList match { case Nil = Null case x = new UnprefixedAttribute(enctype, Text(multipart/ form-data), Null) } As im not familiar with the MetaData class, I wasn't sure how best to alter this. It seems we have 3 cases: unprefixed attributes, prefixed attributes and null. Perhaps some kind of flatmap/map or something to itterate through the attributes and return the appropriate object. Anyway, i must dash - cheers guys Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Lift, Jetty and OneJar
David Bernard wrote: There is a maven plugin that allow to do it with winstone instead of jetty: http://alchim.sourceforge.net/winstone-maven-plugin/usage.html I found this. I need Jetty for continuations... thus Winstone is not my first choice. Thanks, David /davidB On Tue, Sep 16, 2008 at 2:08 PM, Derek Chen-Becker [EMAIL PROTECTED] wrote: Do you mean a JAR that you can just run, a la java -jar mywebapp.jar ? On Mon, Sep 15, 2008 at 5:25 PM, David Pollak [EMAIL PROTECTED] wrote: Folks, Has anyone built a Lift app that's deployable as a JAR file with Jetty as the container? Thanks, David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA Table annotation
That's cleaner. I'll try it. Thanks, Chas. Derek Chen-Becker wrote: Technically you can drop the constructor parens as well so it looks like @Table{val name=roles} Derek On Mon, Sep 15, 2008 at 5:08 PM, Tim Perrett [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Chas, Change you annotation to this: @Table(){val name=roles} Scrap the xml attribute, then it will work no problems. This is the convention for using jpa annotations in scala. Doing this works perfectly for me. Cheers Tim Sent from my iPhone On 15 Sep 2008, at 23:43, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: When I use the @Table annotation to set the table name for JPA, thus: @Entity @Table(name=ROLES) class Role It belches out that Table does not have the correct number of arguments. I tried just setting it in the orm.xml file, thus: entity class=Role table name=roles/ /entity And now I get a roles table, but also a role table. Any ideas what's going on here? The annotation syntax seems correct, but maybe this is a Scala issue? Chas. To stave off the inevitable question :-), the reason I want to do this is because I want a User class, but user is a reserved word in PostgreSQL. Also, I like plural table names better (even though that is not the classic RDBMS way). And I'd like the table naming to be consistent. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Custom snippet attributes
It looks to me like a typo bug in LiftSession.porcessSnippet: For instance at the end of this function we have: attrs.get(form).map(ft = ( (form action={S.uri} method={ft.text}{ret}/form % checkMultiPart(attrs)) % checkAttr(class, attrs)) % checkAttr(id,attrs) ) getOrElse ret attrs.get(form).map(ft = form action={S.uri} method={ft.text}{ret}/form % checkMultiPart(attrs)) getOrElse ret the first call seems to handle id and class attributes but actually the function returns the result of the last expression which doesn't care about id and class attributes. So sems to me that the fix would be to just remove the last line: attrs.get(form).map(ft = form action={S.uri} method={ft.text}{ret}/form % checkMultiPart(attrs)) getOrElse ret Br's, Marius On Sep 16, 4:54 pm, Tim Perrett [EMAIL PROTECTED] wrote: Hey guys, If you have a call like: lift:mysnippet form=post is translated to form method=post action=blah however, is there a way to set the id attribute on that node? Simply adding the id in the markup is removed by lifts processing, so thats no good as most javascript / css things either need id or class to select the appropriate element. As im on a tight timeline with something, I just hacked the code to make it work with the id attribute (i know thats bad!) - we need a better solution really, and one that can accommodate any custom user attributes. Currently, the lift head looks like: def checkAttr(attr_name: String, in: MetaData): MetaData = in.filter(_.key == attr_name).toList match { case Nil = Null case x = new UnprefixedAttribute(attr_name, Text(x.first.value.text), Null) } attrs.get(form).map(ft = ( (form action={S.uri} method={ft.text}{ret}/form % checkMultiPart(attrs)) % checkAttr(class, attrs)) % checkAttr(id,attrs) ) getOrElse ret attrs.get(form).map(ft = form action={S.uri} method={ft.text}{ret}/form % checkMultiPart(attrs)) getOrElse ret } def checkMultiPart(in: MetaData): MetaData = in.filter(_.key == multipart).toList match { case Nil = Null case x = new UnprefixedAttribute(enctype, Text(multipart/ form-data), Null) } As im not familiar with the MetaData class, I wasn't sure how best to alter this. It seems we have 3 cases: unprefixed attributes, prefixed attributes and null. Perhaps some kind of flatmap/map or something to itterate through the attributes and return the appropriate object. Anyway, i must dash - cheers guys Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Massive Twitter Updates
You might ask this question on the GitHub list. Jorge Ortiz wrote: If you're following @liftweb on Twitter, I apologize for the massive updates tonight. It seems that whenever I merge changes from 'master' into 'scala-snapshot', all those commits get re-tweeted by Github. Anyone know if there's any way to disable tweeting of commits not made to the 'master' branch, or disable tweeting of commits that have already been made to another branch (and so already tweeted once)? --j --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: snippets and html
Jorge Ortiz wrote: The mixinAttributes function is now in BindHelpers. Excellent! Thanks! --j On Fri, Aug 15, 2008 at 7:06 AM, David Pollak [EMAIL PROTECTED] wrote: On Thu, Aug 14, 2008 at 10:42 AM, Jorge Ortiz [EMAIL PROTECTED] wrote: The abstraction for it isn't baked into lift, but because Scala is a functional, high-level language it's not hard to write it as an abstraction yourself. The way we've been growing Lift is to find abstractions that are used in the wild, generalizing them, and making them part of Lift. This one strikes me as something that should be rolled in. Jorge -- want to add the code? def mixinAttributes(out: Elem)(in: NodeSeq): NodeSeq = in.firstOption.map(out % _.attributes).getOrElse(out) Then you can do: bind(hello, xhtml, email -- mixinAttributes(SHtml.text(email, email = _))) You can even give it a shorter name if you want. --j On Thu, Aug 14, 2008 at 7:46 AM, Oliver Lambert [EMAIL PROTECTED] wrote: Good to know its possible though it looks like a little work to set up as a default. On 14/08/2008, at 8:43 PM, Jorge Ortiz wrote: Try passing a NodeSeq = NodeSeq function to bind, like so: bind(hello, xhtml, email -- (inputField: NodeSeq) = { /* extract attributes from inputField and mix into result from SHtml.text */ }) inputField should get bound to whatever is inside the hello:email tags in your xhtml (in this case, input ...) --j On Wed, Aug 13, 2008 at 11:22 PM, Oliver [EMAIL PROTECTED] wrote: Suppose I have the following snippet of html /tdtdhello:emailinput maxlength=50 size=35 id=email//hello:email/td and the following snippet of a snippet bind(hello, xhtml, email -- text(email, email = _), ... The SHtml.text method overwrites the input html inside hello:email getting rid of my maxlength and size. Is there any way to keep my current attributes and combine them with the SHtml.text output? I know I can call '% (size - 10)' on the function, but I would rather have most of my html in a text file. cheers Oliver -- lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---