--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
On Sunday, May 30, 2010, green <green...@gmail.com> wrote:
> It's the case in my Play version (v1.0.2.1). The model hierarchy in this version is
> models.MyBaseModel - > play.db.jpa.Model ->play.db.jpa.JPASupport
> It looks "SupperClass" in your code is missing from my model hierarchy. I will try it and come back
>
> Thanks!Green
>
> On Sun, May 30, 2010 at 10:22 PM, Archer Yongjian Liu <yl...@kalengo.com> wrote:
> Do you want to override the id field mapping using @AttributeOverride ?
> JPABase is the class provided by Play!
>
>
>
>
> On Sun, May 30, 2010 at 8:03 PM, green <green...@gmail.com> wrote:
> Thanks Archer. By "adding an new ID" I mean override ID field definition in play.db.jpa.Model in the sub class.
>
>
> BTW, what is JPABase in your code?
>
> On Sun, May 30, 2010 at 5:11 PM, Archer Yongjian Liu <yl...@kalengo.com> wrote:
> I have encounter this problem before. What do you mean 'by adding new ID to sub model class' ?
>
>
>
> Can you give an example ?Do you use Java or Scala ?
> When I do this in scala: @Entity@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)abstract class SupperClass extends Model{
>
>
>
> @Id @GeneratedValue(strategy =GenerationType.TABLE, generator = "SEQ_TABLE") @TableGenerator(name = "SEQ_TABLE") override def getId() = super.getId() /* ---------------- it does not take effect here ----------------*/
>
>
>
>
> // Other SupperClass attributes
> }
> @Entityclass MySubClass1 extends SupperClass{ //Other MySubClass1 attributes
> }
>
>
>
>
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------
> However, we can't override id attribute in scala because it is defined as mutable variable in superclass
>
>
>
>
> So, I create a new class named MyModel , which only replace the id definition as follow:
> class MyModel extends JPABase{ ....
> // only changes here
>
>
>
> @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "SEQ_TABLE") @TableGenerator(name = "SEQ_TABLE") var id: Long = _}
>
> Then redefine the poso:@Entity@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)abstract class SupperClass extends MyModel{ // Other SupperClass attributes
>
>
>
> }
> @Entityclass MySubClass1 extends SupperClass{ //Other MySubClass1 attributes
JPA errorA JPA error occurred (Unable to build EntityManagerFactory): Cannot use identity column key generation with <union-subclass> mapping for: models.OooiMessage