- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
JPA @AttributeOverrides Annotation
Thu, 2009-04-02, 05:31
How does one use the JPA @AttributeOverrides annotation in scala?
I have this that working in Java:
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "DAY", column = @Column(name = "MONDAY")),
@AttributeOverride(name = "HOURS",
column = @Column(name = "MONDAY_HRS"))
})
private DayHours monday;
I haven't found any examples on-line that use @AttributeOverrides, and I've what
I'velearned from the lift source code, but I still haven't stumbled onto the
solution. I've tried working with this, and replacing parens with braces:
@Embedded
@AttributeOverrides({
@AttributeOverride(val name = "day",
val column = @Column{val name = "MONDAY"}),
@AttributeOverride(val name = "hours",
val column = @Column{val name = "MONDAY_HRS"})
})
Can anyone recommend some JPA samples?
Thu, 2009-04-02, 09:17
#2
Re: JPA @AttributeOverrides Annotation
kxen schrieb:
> Can anyone recommend some JPA samples?
I have written something down there:
http://www.hars.de/2009/03/jpa-with-scala.html
The picture is a bit mixed at the moment. The things that
work are very elegant, some things are plain impossible (like
the @AttributeOverrides you are asking about), and what works
works only in eclipselink and only by chance. I just filed a
ticket for that: https://lampsvn.epfl.ch/trac/scala/ticket/1846
- Florian.
Thu, 2009-04-02, 09:47
#3
Re: JPA @AttributeOverrides Annotation
For those interested, I have been working on Ebean ORM which also uses JPA annotations.
The latest version works with Scala. This includes support for Scala's property convention (so you don't need the @BeanProperty annotation).
However, I have to say I am very new to Scala so there is a probably lots of things that could be done better (I didn't know anything about case class for example).
Ebean
=======
- uses JPA annotations @Entity @OneToMany etc
- has a "Session less" API ... so no merge, flush
- uses DB metadata where possible (No @JoinColumn etc required if you have foreign keys)
- has Automatic query tuning (based on profiling object graph use)
- Open Source LGPL
You can find Ebean at http://www.avaje.org
If anyone has any ideas, thoughts, feedback etc on how to make Ebean / Scala integration better I'd be very interested to here them.
Thanks for the link Florian. I'll have to try out the case class.
Thanks, Rob.
From: Florian Hars <hars@bik-gmbh.de>
To: kxen <biznezonly@mac.com>
Cc: scala-user@listes.epfl.ch
Sent: Thursday, April 2, 2009 9:08:37 PM
Subject: Re: [scala-user] JPA @AttributeOverrides Annotation
kxen schrieb:
> Can anyone recommend some JPA samples?
I have written something down there:
http://www.hars.de/2009/03/jpa-with-scala.html
The picture is a bit mixed at the moment. The things that
work are very elegant, some things are plain impossible (like
the @AttributeOverrides you are asking about), and what works
works only in eclipselink and only by chance. I just filed a
ticket for that: https://lampsvn.epfl.ch/trac/scala/ticket/1846
- Florian.
Thu, 2009-04-02, 15:17
#4
Re: JPA @AttributeOverrides Annotation
rob bygrave schrieb:
> For those interested, I have been working on Ebean ORM which also uses
> JPA annotations.
>
> The latest version works with Scala. This includes support for Scala's
> property convention (so you don't need the @BeanProperty annotation).
You're right, it looks like they may be unnecessary with eclipselink, too
(at least the generated getters and setters are not annotated). They are
left in my code because I needed them for some other experiments anyway
and never thought about testing the code without them.
- Florian.
Thu, 2009-04-02, 15:47
#5
Re: JPA @AttributeOverrides Annotation
FWIW... here's the Lift JPA wiki page http://wiki.liftweb.net/index.php?title=Lift_and_JPA_(javax.persistence)
On Wed, Apr 1, 2009 at 9:31 PM, kxen <biznezonly@mac.com> wrote:
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp
On Wed, Apr 1, 2009 at 9:31 PM, kxen <biznezonly@mac.com> wrote:
How does one use the JPA @AttributeOverrides annotation in scala?
I have this that working in Java:
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "DAY", column = @Column(name = "MONDAY")),
@AttributeOverride(name = "HOURS",
column = @Column(name = "MONDAY_HRS"))
})
private DayHours monday;
I haven't found any examples on-line that use @AttributeOverrides, and I've what
I'velearned from the lift source code, but I still haven't stumbled onto the
solution. I've tried working with this, and replacing parens with braces:
@Embedded
@AttributeOverrides({
@AttributeOverride(val name = "day",
val column = @Column{val name = "MONDAY"}),
@AttributeOverride(val name = "hours",
val column = @Column{val name = "MONDAY_HRS"})
})
Can anyone recommend some JPA samples?
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp
Thu, 2009-04-02, 16:07
#6
Re: JPA @AttributeOverrides Annotation
On Thursday April 2 2009, David Pollak wrote:
> FWIW... here's the Lift JPA wiki page
>
"There is currently no text in this page, you can search for this page
title in other pages or edit this page"
That's the case if you use either of these:
Furthermore, using the search function with the term "JPA" yields
neither page title nor text matches.
Randall Schulz
Thu, 2009-04-02, 16:17
#7
Re: JPA @AttributeOverrides Annotation
On Thu, Apr 2, 2009 at 4:56 PM, Randall R Schulz <rschulz@sonic.net> wrote:
On Thursday April 2 2009, David Pollak wrote:
> FWIW... here's the Lift JPA wiki page
><http://wiki.liftweb.net/index.php?title=Lift_and_JPA_(javax.persistence)>
"There is currently no text in this page, you can search for this page
title in other pages or edit this page"
Works for me...
That's the case if you use either of these:
<http://wiki.liftweb.net/index.php?title=Lift_and_JPA(javax.persistence)>
<http://wiki.liftweb.net/index.php?title=Lift_and_JPA>
Furthermore, using the search function with the term "JPA" yields
neither page title nor text matches.
Randall Schulz
--
Viktor Klang
Senior Systems Analyst
Thu, 2009-04-02, 16:27
#8
Re: JPA @AttributeOverrides Annotation
Randall R Schulz schrieb:
> That's the case if you use either of these:
If the wrong links you made up don't work, then use the correct
link David posted ;-).
- Florian.
Thu, 2009-04-02, 18:17
#9
Re: JPA @AttributeOverrides Annotation
> Sorry, it seems this isn't possible yet:
> https://lampsvn.epfl.ch/trac/scala/ticket/294
>
You have to use the orm.xml mapping file instead. There's an example of
using the orm.xml file in the Lift JPA Demo site:
http://github.com/dpp/liftweb/blob/4a5d4530b407782a2f0e0e99b277432dbb41b...
Derek
Thu, 2009-04-02, 18:27
#10
Re: JPA @AttributeOverrides Annotation
rob bygrave wrote:
>
> Ebean
> =======
> - uses JPA annotations @Entity @OneToMany etc
> - has a "Session less" API ... so no merge, flush
> - uses DB metadata where possible (No @JoinColumn etc required if you
> have foreign keys)
> - has Automatic query tuning (based on profiling object graph use)
> - Open Source LGPL
EBean looks interesting. I'll have to check that out :)
Derek
kxen wrote:
>
> How does one use the JPA @AttributeOverrides annotation in scala?
>
> I have this that working in Java:
> @Embedded
> @AttributeOverrides({
> @AttributeOverride(name = "DAY", column = @Column(name = "MONDAY")),
> @AttributeOverride(name = "HOURS",
> column = @Column(name = "MONDAY_HRS"))
> })
> private DayHours monday;
>
> I haven't found any examples on-line that use @AttributeOverrides, and
> I've what
> I'velearned from the lift source code, but I still haven't stumbled onto
> the
> solution. I've tried working with this, and replacing parens with braces:
>
> @Embedded
> @AttributeOverrides({
> @AttributeOverride(val name = "day",
> val column = @Column{val name = "MONDAY"}),
> @AttributeOverride(val name = "hours",
> val column = @Column{val name = "MONDAY_HRS"})
> })
>
>
> Can anyone recommend some JPA samples?
>
>
>
Sorry, it seems this isn't possible yet:
https://lampsvn.epfl.ch/trac/scala/ticket/294