But I'm not constructing the same object. I get it from database, store in session variable, and then put it in new Article object, as needed. Here's important code:
check if User object is stored in database, and if User is returned, stores it in session variable.
korbean.kor = korbean.postojiLiKorisnikLogin(email,password);
if (korbean.kor != null) {
session.setAttribute("userloggedin", korbean.kor);
session.setAttribute("username", request.getParameter("email"));
}
method that returns object Korisnik (actually User), if one exists
public Korisnik postojiLiKorisnikLogin(String email, String password) {
Korisnik prototip = new Korisnik(email,password,null,null);
ObjectContainer oc = Db4oUtil.getObjectContainer();
ObjectSet rezultat = oc.get(prototip);
if (!rezultat.isEmpty()) { return (Korisnik)rezultat.get(0); }
else return null;
}
method that adds new Article to database, you see the Korisnik (User) object at the end...
public void dodajArtikal(String proizvodjac, String model, double cena, char transakcija, char stanje, Korisnik korisnik) {
Artikal a = new Artikal (proizvodjac, model, cena, transakcija, stanje, korisnik);
ObjectContainer oc = Db4oUtil.getObjectContainer();
oc.set(a);
Db4oUtil.closeObjectContainer();
}
I'm stuck, everything is logical to me, what to say else .. :) And I'm nervous, I was thinking this whole thing with db4o would be easier to me.. :(