线程“main”中的异常org.hibernate.PropertyValueException:not-null属性引用null或transient值:table.Login.lastlogin

时间:2016-05-07 18:29:12

标签: hibernate java-ee

static void signUp(String u,String p,String cp)
{
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter User Name");
    u=sc.nextLine();
    Session s = HIBDAOLayer.getSession();
    Criteria c =s.createCriteria(table.Login.class);
    c.add(Restrictions.eq("lid", u));
    List<Login> data = c.list();
    if(data.size()>0)
        System.out.println("Username Already Exist/nPlease Choose another user name");
    else
    {
    System.out.println("Enter Password");
    p=sc.nextLine();
    System.out.println("Confirm Your Password");
    cp=sc.nextLine();

    //e.setSalary(sal);
    if(p.equals(cp))
    { 
    Login l = new Login();
 //   l.setLastlogin();
    l.setLid(u);
    l.setPass(p);
   // Session s = HIBDAOLayer.getSession();
    Transaction t = s.beginTransaction();
    s.save(l);
    t.commit();
        System.out.println("You Are Successfully Registered With Us");

    }
    else
        System.out.println("Password Doesn't Match");
}

我的表包含四个属性lid,pass,role,lastlogin,其中role和lastlogin是默认值。

我认为问题在于lastlogin的数据类型是时间戳,默认是CURRENT_TIMESTAMP。

0 个答案:

没有答案