create table Test(id integer primary key, value varchar(20))
@Entity@Table(name="test")public class Test {// @Id private int id; private String value;/* the setter and getter ??????*/}
TestCase:public void testGetAllTests() { List<Test> tests = Ebean.find(Test.class).findList(); assertEquals(2,tests.size()); assertNull(tests.get(0)); assertNull(tests.get(1));}
Note the List containing nulls.
Similar issue can occur with @SqlSelect on an entity with no @Id defined.
http://docs.google.com/Doc?id=ddh2svk9_59gfsrgsgk
Documented Testcase .
Thanks. This is a good bug.
... I'll have a look in more detail later but my initial thoughts are ...
Any @Entity without an @Id has a couple of issues.
1. It can't be persisted by default (no insert/update/delete support)2. It can't be effectively put/get from the "Persistence Context"
The issue around SqlTreeNodeBean.load()... is that the code is assuming the entity has an Id (to see if it is already in the persistence context already and hence won't be loaded/populated from the resultSet).
... aka the nulls in the list are result of this incorrect assumption / bug (there is no Id but it is not already in the persistence context - and never will be because it will never have an id).
So, I'll have to look in more detail... but I'm thinking if an Entity doesn't have a @Id .. I need to handle these issues in SqlTreeNodeBean... and also in the persistence logic.
There may be some special handling for SqlSelect ... but I'll need to look at that.
Cheers, Rob.
http://docs.google.com/View?id=ddh2svk9_59gfsrgsgkThe url is better, everyone can access it.