標籤:des io java for sp 資料 on cti ad
給的資料庫模型是sql2005的,然後在powerdesigner把資料庫模型改成mysql的去建實體,建不上,貌似好多東西要改。
要做以下幾件事:
1,加上uuid的東西,產生唯一id,類型是String,Java中實體類主鍵上加
@GenericGenerator(name="systemUUID",strategy="uuid")
@GeneratedValue(generator="systemUUID")
有些用自增的感覺會比較好些。
2,要把int類型改成integer,因為int的預設值是0,插入會有預設值。
3,貌似hibernate直接產生的關係都是一對多的,一對一的忘記怎麼弄了,還有多對多的還要建第三方表,明天要研究研究這個。
4,每個表的遞增流水號不知道是幹什麼的。
其他:
[11-05 13:43:36] [RMI TCP Connection(3)-127.0.0.1] [ERROR][org.springframework.web.context.ContextLoader-331]-Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory‘ defined in class path resource [application-context.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.shinowit.entity.TMeStockInfo column: MerchandiseID (should be mapped with insert="false" update="false")
百度說是不同的屬性對應為相同的欄位,重複映射同一個欄位,就會出現這個錯誤;
還沒解決。
解決方案:
確實是不同的屬性對應了相同的欄位,比如之前有一個
private int roleId;
我又加了一個一對多的關係
privateRole role;
並且Role裡有roleId,這就重複映射了,在通過表建實體的時候不要勾選roleId就可以了。
關於hibernate實體類