0

In this doc we can see example of usage @CollectioTable annotation

I wrote the same code

@Entity public class Person {
       @ElementCollection
       @CollectionTable(name="HOMES", joinColumns = @Column(name = "PERSON_ID"))  
       @Column(name="HOME_STATE")
       protected List<String> vacationHomes;
       ...
    }  

Usinf Hibernate-jpa-2 version 1.0.0.Final

Deploy on JBoss 4.3.0.GA

And get exception (while deploying), that column HOME_STATE cann't be mapped on java.util.List

so I change List to ArrayList

After that application was deployed well.
But doesn't work well! I execute simple query, but annotations @ElementCollection and @CollectionTable were ignored! Working only @Column annotation

Can be problem with old JBoss version?
I don't know where problem...

Community
  • 1
  • 1
Ilya
  • 29,135
  • 19
  • 110
  • 158

1 Answers1

3

Features that are part of JPA 2.0 are not working. That's because of missing implementation. In this case, only new annotations are there, but no processing (hibernate-jpa-2.0-api-1.0.0.Final is only JPA 2.0 interface, not the implementation).

According releases notes JBoss 4.3.0.GA was shipped with Hibernate 3.2.1, which is not JPA 2.0 implementation.

Making it work is next from impossible also with JBoss 5, as you can read from this question. If you cannot update at least to the JBoss 6.x, then it is easier to stick with JPA 1.

Community
  • 1
  • 1
Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135
  • So bad. '@ElementCollection' since JPA 2, but I am using JBoss 4.3.0.GA :-( – Ilya Apr 28 '12 at 19:56
  • With hibernate xml mapping I cann't use Element-Collection too? – Ilya Apr 28 '12 at 21:20
  • Same limitation is there. But if you are ready to discard JPA compatibility and use Hibernate specific solution, CollectionOfElements is likely answer. Looks like it is part of hibernate annotations 3.2.1: http://www.jarvana.com/jarvana/view/org/hibernate/hibernate-annotations/3.2.1.ga/hibernate-annotations-3.2.1.ga.jar!/org/hibernate/annotations/CollectionOfElements.class?classDetails=ok – Mikko Maunu Apr 29 '12 at 11:28