关于使用hibernate的session的save()方法的问题
我使用hibernated中的session的save()方法来向数据库的表中添加新的字段,以此来替代sql语句的添加方法。可是却产生了下面的异常:
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.wgh.ORM.TbTaoTi.joinTime
at org.hibernate.engine.Nullability.checkNullability
……
下面是hbm.xml的内容:
<property name="joinTime" type="java.sql.Timestamp">
<column name="JoinTime" length="23" not-null="true" />
</property>
下面是我的代码:
lesson=(TbLesson)session.get(TbLesson.class, (long)taoTiForm.getLessonId());
taoti=new TbTaoTi();
taoti.setName(taoTiForm.getName());
taoti.setTbLesson(lesson);
session.save(taoti);
我知道这里的时间是必须不能为空的,但是在使用纯sql语句进行添加时就因为表中的那个时间字段是使用了getdate()方法的,所以会自动获得,可是我在使用hibernate时这个该怎么弄?