JPAContainer IllegalArgumentException: Not an entity: class com.my.Myclass_

hi
Im using
vaadin 7.9
jpacontainer 3.1.1
hibernate 4.2.6

this code im executing in MyForm

@Override
public void setItemDataSource(Item item, Collection<?> propertyIds) {
super.setItemDataSource(item, propertyIds);
final Field projectGroupField = this.getField("projectGroup");
final Field rdaField = this.getField("rda");
ProjectGroup projectG = (ProjectGroup) projectGroupField.getPropertyDataSource().getValue();
if (projectG == null)
return;
JPAContainer containerDataSource = (JPAContainer) ((ComboBox) projectGroupField)
.getContainerDataSource();
EntityItemProperty itemProperty = containerDataSource.getItem(projectG.getId()).getItemProperty("rdas");
Set<Rda> rdas = (Set<Rda>) itemProperty.getValue();

ArrayList<Filter> filters = new ArrayList<Filter>();
for (Rda rda : rdas) {
filters.add(new Compare.Equal("id", rda.getId()));
}

JPAContainer rdaContainer = (JPAContainer) ((ComboBox) rdaField).getContainerDataSource();
if (adnFilter != null)
rdaContainer.removeContainerFilter(adnFilter);
adnFilter = new And(filters.toArray(new Filter[filters.size()]
));
rdaContainer.addContainerFilter(adnFilter);

getting:

java.lang.IllegalArgumentException: Not an entity: class bee.aquarius.domain.ProjectGroup_$$_javassist_39
at org.hibernate.ejb.metamodel.MetamodelImpl.entity(MetamodelImpl.java:184)
at org.hibernate.ejb.criteria.QueryStructure.from(QueryStructure.java:138)
at org.hibernate.ejb.criteria.CriteriaQueryImpl.from(CriteriaQueryImpl.java:179)
at com.vaadin.addon.jpacontainer.util.HibernateLazyLoadingDelegate.lazilyLoadPropertyValue(HibernateLazyLoadingDelegate.java:76)
at com.vaadin.addon.jpacontainer.util.HibernateLazyLoadingDelegate.ensureLazyPropertyLoaded(HibernateLazyLoadingDelegate.java:58)
at com.my.MyHibernateLazyLoadingDelegate.ensureLazyPropertyLoaded(AquariusHibernateLazyLoadingDelegate.java:15)
at com.vaadin.addon.jpacontainer.JPAContainerItem$ItemProperty.ensurePropertyLoaded(JPAContainerItem.java:256)
at com.vaadin.addon.jpacontainer.JPAContainerItem$ItemProperty.getRealValue(JPAContainerItem.java:175)
at com.vaadin.addon.jpacontainer.JPAContainerItem$ItemProperty.getValue(JPAContainerItem.java:163)

the same code runs without error in the listener

projectGroupField.addValueChangeListener(new ValueChangeListener() {
And adnFilter;

@Override
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
ProjectGroup projectG = (ProjectGroup) projectGroupField.getPropertyDataSource().getValue();
if (projectG == null)
return;
JPAContainer containerDataSource = (JPAContainer) ((ComboBox) projectGroupField)
.getContainerDataSource();
EntityItemProperty itemProperty = containerDataSource.getItem(projectG.getId()).getItemProperty("rdas");
Set<Rda> rdas = (Set<Rda>) itemProperty.getValue();

ArrayList<Filter> filters = new ArrayList<Filter>();
for (Rda rda : rdas) {
filters.add(new Compare.Equal("id", rda.getId()));
}

JPAContainer rdaContainer = (JPAContainer) ((ComboBox) rdaField).getContainerDataSource();
if (adnFilter != null)
rdaContainer.removeContainerFilter(adnFilter);
adnFilter = new And(filters.toArray(new Filter[filters.size()]
));
rdaContainer.addContainerFilter(adnFilter);
}
});

I had a similar problem more than a year ago , but I can for the life of me not remember the specifics of the solution, What I can remember was that is was something stupid I did with an Embedded entity.

I would susgest getting the raw entity bean from the container and inspect its state with a debugger , also I noticed the error occurs with a lazy loaded propery so it might be a transaction context issue ( though this will usually through some Transaction required exception )

Object obj =containerDataSource.getItem(projectG.getId()).getEntity() ;
… check its class, and other properties…

hi Petrus. thanks for reply!

my solution:

in AquariusHibernateLazyLoadingDelegate override

public <E> E ensureLazyPropertyLoaded(E entity, String propertyName) {
        if (entity instanceof HibernateProxy) {
            entity = (E) ((HibernateProxy) entity).getHibernateLazyInitializer().getImplementation();
        }
        entity = super.ensureLazyPropertyLoaded(entity, propertyName);

        return entity;
    }