Strange behavior

4 views
Skip to first unread message

christoph...@gmail.com

unread,
Feb 18, 2012, 11:21:30 AM2/18/12
to Siena
Hi all,

I've got 2 models.

public class Ship extends Model {
@Id
public Long id;

public User user;
}

public class User extends Model {
@Id
public Long id;

public String email;
public String name;
}

On my Ship class, i've got this method :
public static List<Ship> getAlls() {
return Ship.all().fetch();
}

First, I created a Ship like this :

Ship s = new Ship();
s.name = "BB";

User u = User.findById(1L);

s.user = u;
s.save();

When I looked in BD, the raw was correct, user id is ok

When I try to read all ships with this method :
return Model.all(Ship.class).fetch();

ship.user is null

Where's the pb ?

Thxs



Pascal Voitot Dev

unread,
Feb 19, 2012, 7:08:52 AM2/19/12
to siena-...@googlegroups.com
Hi,

Is ship.user completely null or does ship.user.id is not null and the rest of the object is null?

Pascal




--
You received this message because you are subscribed to the Google Groups "Siena" group.
To post to this group, send email to siena-...@googlegroups.com.
To unsubscribe from this group, send email to siena-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/siena-discuss?hl=en.


christoph...@gmail.com

unread,
Feb 19, 2012, 7:42:36 AM2/19/12
to Siena
Object is null.

I've also tried the sample, with Dog and person, and got a bad
result : after person.save(), dog wasn't save in BD.

My env is : play 1.2.3, siena module 2.0.6

Pascal Voitot Dev

unread,
Feb 19, 2012, 7:51:36 AM2/19/12
to siena-...@googlegroups.com
can you try to use insert instead of save please?

christoph...@gmail.com

unread,
Feb 19, 2012, 8:13:21 AM2/19/12
to Siena
Something is really strange, today, I try again the cat and person
sample, now, it's ok :-(

I also tried my models User and Ship after using new copy of them
UserV2 and ShipV2, now it's ok :
user.ship.get() didn't throw NPE..

No lib update, etc...

So Why ?

Pascal Voitot Dev

unread,
Feb 19, 2012, 9:27:47 AM2/19/12
to siena-...@googlegroups.com
hmmm weird :)
are you using GAE?

christoph...@gmail.com

unread,
Feb 19, 2012, 9:31:40 AM2/19/12
to Siena
yep, play 1.2.3, gae 1.6.0, siena 2.0.6

I tried to get siena 2.0.7, now after eclipsify, i've got 2 siena
folders in eclipse :-)

Pascal Voitot Dev

unread,
Feb 19, 2012, 9:33:31 AM2/19/12
to siena-...@googlegroups.com
You should have only one deps to Siena...
Did you run?
play deps --sync

pascal

christoph...@gmail.com

unread,
Feb 19, 2012, 9:48:01 AM2/19/12
to Siena
yep, now it's ok only one siena folder.

I've got 2 play controllers in same application

One simple :

First is :
UserV2 u = UserV2.findById(1L);
u.ship.get();
good result, ship is loaded

Second with @Secure(admin = true) is :
List<UserV2> users = UserV2.getAlls();
for (UserV2 u : users) {
System.out.println(u.name + ":" + u.ship);
}
I've got : null

really hard

christoph...@gmail.com

unread,
Feb 19, 2012, 9:50:18 AM2/19/12
to Siena
More infos, my user seems to be ok in database (H2):

SELECT * FROM USERV2;
ID EMAIL NAME SHIP
1 t...@gmail.com bid 1

Pascal Voitot Dev

unread,
Feb 19, 2012, 9:54:15 AM2/19/12
to siena-...@googlegroups.com
Did you try?
       System.out.println(u.name + ":" + u.ship.get());
Pascal

christoph...@gmail.com

unread,
Feb 19, 2012, 11:12:51 AM2/19/12
to Siena
It's ok for my new model UserV2 and ShipV2, but ko for my old ones

On 19 fév, 15:54, Pascal Voitot Dev <pascal.voitot....@gmail.com>
wrote:
> Did you try?
>        System.out.println(u.name + ":" + u.ship.get());
> Pascal
>
> On Sun, Feb 19, 2012 at 3:48 PM, Christophe.Leche...@gmail.com <

Pascal Voitot Dev

unread,
Feb 19, 2012, 11:16:54 AM2/19/12
to siena-...@googlegroups.com
you should clean your GAE DB to be sure you don't have corrupted data in it.
I really don't see what happened :)

Pascal

christoph...@gmail.com

unread,
Feb 19, 2012, 11:41:04 AM2/19/12
to Siena
thxs for help, perhaps, i will find it.


Reply all
Reply to author
Forward
0 new messages