Hibernate: 3.2.6
Annotations: 3.3.0
EntityManager: 3.3.1
Retrieving all
Category doesn't retrieve all
CategoryDescription.
After executing this query:
Code:
em.createQuery("SELECT c FROM Category c").getResultList()
Retrieving a
CategoryDescription inside a TableModel using
Code:
CategoryDescription description = dataRow.getDescription().get(columnLanguage[columnIndex]);
(where columnLange is an array of
Language objects).
I get a null result for row 0 and column 1.
The following rows return a correct value for column 1.
Inside NetBeans debugger I can see the correct value for row 0 but using the get() function doesn't not return the correct value.
If I chane the @OneToMany definition to @OneToMany(fetch=FetchType.EAGER) row 0 is returned correctly but I don't receive correct results (alwas null) for the last row. Very strange...
The following definitions:
Code:
@Entity
public class Category implements java.io.Serializable {
@Id
@GeneratedValue
private Long id;
@OneToMany
@JoinColumn(name = "CATEGORY_ID")
@MapKey(name="language")
private Map<Language, CategoryDescription> description = new HashMap<Language, CategoryDescription>();
...
@Entity
public class Language implements java.io.Serializable {
@Id
@GeneratedValue
private Long id;
@Column(length=10)
private String code;
...
@Entity
public class CategoryDescription implements java.io.Serializable {
@Id
@GeneratedValue
private Long id;
@ManyToOne(optional=false)
private Language language;
private String text;
...