mysql5以上的方言應(yīng)該是org.hibernate.dialect.MySQL5Dialect
2017-11-17
各位還是別吐槽了。。。具體知識還是要自己看書。。??蠢蠋煹囊曨l更多的是看實際操作和用工具快速的實現(xiàn)。。一些不清楚和錯誤并不妨礙什么
@JoinColumn(name = "BID", referencedColumnName = "cid")
cid:班級實體類的屬性, BID:數(shù)據(jù)庫學(xué)生表表中外鍵字段
這塊,老師上課講反了
cid:班級實體類的屬性, BID:數(shù)據(jù)庫學(xué)生表表中外鍵字段
這塊,老師上課講反了
樓上說的只保存學(xué)生就可以了是不完全正確的,想要如此,首先班級表中要有學(xué)生插入對應(yīng)班級的數(shù)據(jù)。如果沒有,那么必須要保存班級,而且要先保存班級。
為什么插入數(shù)據(jù)庫的String類型的都顯示?號呢?
2017-11-02
import org.hibernate.service.ServiceRegistryBuilder
找不到這個類
找不到這個類
2017-11-01
cascade 是級聯(lián)的,在保存時只保存學(xué)生對象就可以了,會級聯(lián)保存所關(guān)聯(lián)的其它對象
無語了,一直報:
Exception in thread "main" org.hibernate.AnnotationException: Referenced property not a (One|Many)ToOne: com.myspringmvc.myhibernate.otobfk.entity.User.card in mappedBy of com.myspringmvc.myhibernate.otobfk.entity.IdCard.user
Exception in thread "main" org.hibernate.AnnotationException: Referenced property not a (One|Many)ToOne: com.myspringmvc.myhibernate.otobfk.entity.User.card in mappedBy of com.myspringmvc.myhibernate.otobfk.entity.IdCard.user
用getCurrentSession一直報錯,原來是沒在配置文件中添加配置<property name="current_session_context_class">thread</property>
如果@Id一個放在get方法上,一個放在另外一個不同的屬性上,那么最后生成的主鍵只有g(shù)et方法的那一個,屬性的就無效。get方法的優(yōu)先級大于屬性
2017-10-09
我的hibernate用的是5.x版本,直接Configuration config = new Configuration().configure();
config.buildSessionFactory();這樣就能創(chuàng)建數(shù)據(jù)表了
config.buildSessionFactory();這樣就能創(chuàng)建數(shù)據(jù)表了
2017-10-09