Closed almozavr closed 13 years ago
What is type of messages_using_it
field in Java? Can you share a few related fields of Stream
class with us please so that we can locate the bug much easier.
Certainly.
Shortly, every Stream may have many Messages and some Message could belong to only one Stream.
Stream
@Entity
public class Stream extends BasicDbObject<Stream> implements Parcelable {
@PrimaryKey(autoIncrement = true)
private int rowId;
@Index(unique = true)
private long id;
private Message message;
@ManyToOne
private User owner;
private String time;
private String title;
private String privacy;
@OneToMany(toType = Message.class, onField = "stream", load = LoadingPolicy.LAZY)
public EntityList<Stream, Message> messagesUsingIt =
new EntityList(Stream.class, Message.class, this);
@ManyToMany(toType = User.class, load = LoadingPolicy.LAZY)
public EntityList<Stream, User> users =
new EntityList(Stream.class, User.class, this);
...
}
Message
@Entity
public class Message extends BasicDbObject<Message> implements Parcelable {
@PrimaryKey(autoIncrement = true)
private int rowId;
@Index(unique = false)
private long id;
private String text;
private String time;
private long parentMessageId;
private int rating;
@ManyToOne
private Stream stream;
@ManyToOne
private User user;
...
}
BasicDbObject is just a simple abstract helper class
public abstract class BasicDbObject<E> extends Model<E> {
public static String TABLE_COLUMN_ID = "id";
public abstract void copy(E copySource);
public abstract long getId();
}
Also, I must admit that everything works for Stream.insert(). I tested it on 500+ records and it's really fine.
But if I let's say
Stream s = (Stream) fetchSingle(...)
s.update();
It fails with provided error.
Did this solve your problem? Can you please rebuild?
Thanks, great! It seems to work without any error exceptions!
Glad it is solved.
Hi.
I'm forcing with strange update() problem. I have a quite complicated entity which has ManyToMany (or OneToMany) and a problem appears when I try to update entity which is already in DB. So even if I fetch entity from DB and then update the orman fails to do it giving following exception: