Hi,
I’m new to Vaadin and JPAContainer, so hopefully this will be resolved with a quick configuration fix!
I’m using hibernate for persistence and have JPA annotated bean classes representing mysql DB tables and relationships. The bean classes work fine with another (non-Vaadin) project that is using them, and they were generated off of the tables using JBoss Tools’ reverse engineer Hibernate Code Generation tool.
Basically within the bean there are a handful of variables with the necessary getter and setter methods, including those for 2 boolean variables. Well, actually since they are boolean, the booleans have is_() methods instead of get_().
@Entity
@Table(name = "available", catalog = "mediaplayground")
public class Available implements java.io.Serializable {
private Long availabilityId;
private Date dateAvailable;
private Date dateexpires;
private boolean visible;
private boolean deleted;
private String note;
private Set<Property> properties = new HashSet<Property>(0);
private Set<Channel> channels = new HashSet<Channel>(0);
private Set<Media> medias = new HashSet<Media>(0);
public Available() {
}
public Available(Date dateAvailable, Date dateexpires, boolean visible,
boolean deleted) {
this.dateAvailable = dateAvailable;
this.dateexpires = dateexpires;
this.visible = visible;
this.deleted = deleted;
}
public Available(Date dateAvailable, Date dateexpires, boolean visible,
boolean deleted, String note, Set<Property> properties,
Set<Channel> channels, Set<Media> medias) {
this.dateAvailable = dateAvailable;
this.dateexpires = dateexpires;
this.visible = visible;
this.deleted = deleted;
this.note = note;
this.properties = properties;
this.channels = channels;
this.medias = medias;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "availabilityId", unique = true, nullable = false)
public Long getAvailabilityId() {
return this.availabilityId;
}
public void setAvailabilityId(Long availabilityId) {
this.availabilityId = availabilityId;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "dateAvailable", nullable = false, length = 19)
public Date getDateAvailable() {
return this.dateAvailable;
}
public void setDateAvailable(Date dateAvailable) {
this.dateAvailable = dateAvailable;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "dateexpires", nullable = false, length = 19)
public Date getDateexpires() {
return this.dateexpires;
}
public void setDateexpires(Date dateexpires) {
this.dateexpires = dateexpires;
}
@Column(name = "visible", nullable = false)
public boolean isVisible() {
return this.visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
@Column(name = "deleted", nullable = false)
public boolean isDeleted() {
return this.deleted;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
@Column(name = "note", length = 500)
public String getNote() {
return this.note;
}
public void setNote(String note) {
this.note = note;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "available")
public Set<Property> getProperties() {
return this.properties;
}
public void setProperties(Set<Property> properties) {
this.properties = properties;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "available")
public Set<Channel> getChannels() {
return this.channels;
}
public void setChannels(Set<Channel> channels) {
this.channels = channels;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "available")
public Set<Media> getMedias() {
return this.medias;
}
public void setMedias(Set<Media> medias) {
this.medias = medias;
}
}
I was seeing that some fields weren’t being created when I was using a FieldFactory, so I started tracing it backwards.
I create a new JPAContainer using JPAContainerFactory:
JPAContainer<Available> availContainer = JPAContainerFactory.makeNonCached(Available.class, PublishConstants.PERSISTENCE_MEDIA);
however the properties that should represent the 2 booleans aren’t there. This snippet:
System.out.println("\navailContainer getContinerPropertyIds:");
Collection availContainerCol = availContainer.getContainerPropertyIds();
for (Object o:availContainerCol)
{
System.out.println("-> "+(String)o);
}
outputs this:
See how there are no properties for ‘visible’ or ‘deleted’. So for kicks I tried to create a BeanContainer out of the Available.class to see what fields it can find:
BeanContainer availBeanContainer = new BeanContainer(Available.class);
and this snippet:
System.out.println("\navailBeanContainer getContinerPropertyIds:");
Collection availBeanContainerCol = availBeanContainer.getContainerPropertyIds();
for (Object o:availBeanContainerCol)
{
System.out.println("-> "+(String)o);
}
outputs this:
So the ‘visible’ and ‘deleted’ properties found when using BeanContainer, but not with JPAContainer. Ceratinly I want to use JPAContainer so it can be persisted, and I need access to those fields, preferably without needing to add them manually after creating the container (but I will if I have to!). Note that the ‘note’ field is a simple column entry in the table, and it’s found - though it is a different datatype.
Does JPAContainerFactory find booleans?
What am I doing wrong that is causing JPAContainer to not find those properties?
thanks!