2016-08-31 27 views
0

我試圖用netbeans 8.1上的休眠4.3和MySQL 5.6生成我的持久層,但每次它創建重複的字段。休眠在Pojos上重複字段映射

這裏是我得到的一個例子:


private Set<Cliente> clientes = new HashSet<Cliente>(0); 
private Set<Cliente> clientes_1 = new HashSet<Cliente>(0); 
private Set<Compra> compras = new HashSet<Compra>(0); 
private Set<Compra> compras_1 = new HashSet<Compra>(0); 
private Set<Cotizacion> cotizacions = new HashSet<Cotizacion>(0); 
private Set<Cotizacion> cotizacions_1 = new HashSet<Cotizacion>(0); 
private Set<Credito> creditos = new HashSet<Credito>(0); 
private Set<Credito> creditos_1 = new HashSet<Credito>(0); 
private Set<Cuenta> cuentas = new HashSet<Cuenta>(0); 
private Set<Cuenta> cuentas_1 = new HashSet<Cuenta>(0); 

此問題是由Hibernate生成的每個實體。我也試過最新的休眠版本是5.2,同樣的問題發生。

回答

0

當hibernate.hbm2ddl.auto *屬性設置爲** update時,如果從舊版本的hibernate更新到新版本(4.3到5.2),我發現這個問題迫使hibernate重新創建約束,在舊數據庫中留下舊數據庫時,下次嘗試重新創建持久層時,會發生這種情況。hibernate並未將舊約束條件理解爲關係,因此它會創建新屬性。