Christian Filippi [https://community.jboss.org/people/christian1976] created the discussion
"Re: How to avoid should be mapped with insert="false" update="false""
To view the discussion, visit: https://community.jboss.org/message/799035#799035
--------------------------------------------------------------
hello,
my sql schema is:
CREATE TABLE `SIC-AMM-Aziende` (
 `SAA-id` int(5) NOT NULL,
 `SAA-cat_id` int(2) DEFAULT NULL,
 `SAA-ragione_sociale` varchar(100) DEFAULT NULL,
 `SAA-piva` varchar(11) DEFAULT NULL,
 `SAA-note` varchar(300) DEFAULT NULL,
 `SAA-indirizzo-std` int(5) DEFAULT NULL,
 `SAA-pagamento-std` int(2) DEFAULT '0',
 PRIMARY KEY (`SAA-id`),
 KEY `SAA-cat_id` (`SAA-cat_id`),
 KEY `SAA-indirizzo-std` (`SAA-indirizzo-std`),
 KEY `SAA-pagamento-std` (`SAA-pagamento-std`),
 CONSTRAINT `***@002dAMM@002dAziende_ibfk_1` FOREIGN KEY (`SAA-indirizzo-std`) REFERENCES `SIC-AMM-Indirizzi` (`SAI-id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
 CONSTRAINT `***@002dAMM@002dAziende_ibfk_2` FOREIGN KEY (`SAA-pagamento-std`) REFERENCES `SIC-AMM-Pagamenti` (`SAP-id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$
CREATE TABLE `SIC-AMM-Scadenze` (
 `SAS-id` int(11) NOT NULL,
 `SAS-ordine` int(11) DEFAULT NULL,
 `SAS-fornitore` int(5) DEFAULT NULL,
 `SAS-data` date DEFAULT NULL,
 `SAS-banca` tinyint(4) DEFAULT NULL,
 `SAS-importo` double DEFAULT NULL,
 `SAS-scaduto` enum('N','Y') DEFAULT NULL,
 PRIMARY KEY (`SAS-id`),
 KEY `SAS-ordine` (`SAS-ordine`),
 KEY `SAS-fornitore` (`SAS-fornitore`),
 KEY `SAS-banca` (`SAS-banca`),
 CONSTRAINT `SAS-banca` FOREIGN KEY (`SAS-banca`) REFERENCES `SIC-AMM-Banche` (`SAB-id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
 CONSTRAINT `SAS-fornitore` FOREIGN KEY (`SAS-fornitore`) REFERENCES `SIC-AMM-Aziende` (`SAA-id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
 CONSTRAINT `SAS-ordine` FOREIGN KEY (`SAS-ordine`) REFERENCES `SIC-COM-Ordini` (`SCR-id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$
Please note the foreign key
CONSTRAINT `SAS-fornitore` FOREIGN KEY (`SAS-fornitore`) REFERENCES `SIC-AMM-Aziende` (`SAA-id`) ON DELETE NO ACTION ON UPDATE NO ACTION in SIC-AMM-Scadenze Table.
Generated Java code:
package it.scm.hibernate;
// Generated Feb 22, 2013 9:46:34 AM by Hibernate Tools 3.4.0.CR1
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
* SicAmmAziende generated by hbm2java
*/
@Entity
@Table(name = "SIC-AMM-Aziende", catalog = "SICIMI_DB")
public class SicAmmAziende implements java.io.Serializable {
         private int saaId;
         private Integer saaCatId;
         private String saaRagioneSociale;
         private String saaPiva;
         private String saaNote;
         private Integer saaIndirizzoStd;
         private Integer saaPagamentoStd;
         private Set<SicAmmScadenze> sicAmmScadenzes = new HashSet<SicAmmScadenze>(0);
         public SicAmmAziende() {
         }
         public SicAmmAziende(int saaId) {
                   this.saaId = saaId;
         }
         public SicAmmAziende(int saaId, Integer saaCatId, String saaRagioneSociale,
                             String saaPiva, String saaNote, Integer saaIndirizzoStd,
                             Integer saaPagamentoStd, Set<SicAmmScadenze> sicAmmScadenzes) {
                   this.saaId = saaId;
                   this.saaCatId = saaCatId;
                   this.saaRagioneSociale = saaRagioneSociale;
                   this.saaPiva = saaPiva;
                   this.saaNote = saaNote;
                   this.saaIndirizzoStd = saaIndirizzoStd;
                   this.saaPagamentoStd = saaPagamentoStd;
                   this.sicAmmScadenzes = sicAmmScadenzes;
         }
         @Id
         @Column(name = "SAA-id", unique = true, nullable = false)
         public int getSaaId() {
                   return this.saaId;
         }
         public void setSaaId(int saaId) {
                   this.saaId = saaId;
         }
         @Column(name = "SAA-cat_id")
         public Integer getSaaCatId() {
                   return this.saaCatId;
         }
         public void setSaaCatId(Integer saaCatId) {
                   this.saaCatId = saaCatId;
         }
         @Column(name = "SAA-ragione_sociale", length = 100)
         public String getSaaRagioneSociale() {
                   return this.saaRagioneSociale;
         }
         public void setSaaRagioneSociale(String saaRagioneSociale) {
                   this.saaRagioneSociale = saaRagioneSociale;
         }
         @Column(name = "SAA-piva", length = 11)
         public String getSaaPiva() {
                   return this.saaPiva;
         }
         public void setSaaPiva(String saaPiva) {
                   this.saaPiva = saaPiva;
         }
         @Column(name = "SAA-note", length = 300)
         public String getSaaNote() {
                   return this.saaNote;
         }
         public void setSaaNote(String saaNote) {
                   this.saaNote = saaNote;
         }
         @Column(name = "SAA-indirizzo-std")
         public Integer getSaaIndirizzoStd() {
                   return this.saaIndirizzoStd;
         }
         public void setSaaIndirizzoStd(Integer saaIndirizzoStd) {
                   this.saaIndirizzoStd = saaIndirizzoStd;
         }
         @Column(name = "SAA-pagamento-std")
         public Integer getSaaPagamentoStd() {
                   return this.saaPagamentoStd;
         }
         public void setSaaPagamentoStd(Integer saaPagamentoStd) {
                   this.saaPagamentoStd = saaPagamentoStd;
         }
         @OneToMany(fetch = FetchType.LAZY, mappedBy = "sicAmmAziende")
         public Set<SicAmmScadenze> getSicAmmScadenzes() {
                   return this.sicAmmScadenzes;
         }
         public void setSicAmmScadenzes(Set<SicAmmScadenze> sicAmmScadenzes) {
                   this.sicAmmScadenzes = sicAmmScadenzes;
         }
}
package it.scm.hibernate;
// Generated Feb 22, 2013 9:46:34 AM by Hibernate Tools 3.4.0.CR1
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* SicAmmScadenze generated by hbm2java
*/
@Entity
@Table(name = "SIC-AMM-Scadenze", catalog = "SICIMI_DB")
public class SicAmmScadenze implements java.io.Serializable {
         private int sasId;
         private SicAmmAziende sicAmmAziende;
         private Integer sasOrdine;
         private Integer sasFornitore;
         private Date sasData;
         private Byte sasBanca;
         private Double sasImporto;
         private String sasScaduto;
         public SicAmmScadenze() {
         }
         public SicAmmScadenze(int sasId) {
                   this.sasId = sasId;
         }
         public SicAmmScadenze(int sasId, SicAmmAziende sicAmmAziende,
                             Integer sasOrdine, Integer sasFornitore, Date sasData,
                             Byte sasBanca, Double sasImporto, String sasScaduto) {
                   this.sasId = sasId;
                   this.sicAmmAziende = sicAmmAziende;
                   this.sasOrdine = sasOrdine;
                   this.sasFornitore = sasFornitore;
                   this.sasData = sasData;
                   this.sasBanca = sasBanca;
                   this.sasImporto = sasImporto;
                   this.sasScaduto = sasScaduto;
         }
         @Id
         @Column(name = "SAS-id", unique = true, nullable = false)
         public int getSasId() {
                   return this.sasId;
         }
         public void setSasId(int sasId) {
                   this.sasId = sasId;
         }
         @ManyToOne(fetch = FetchType.LAZY)
         @JoinColumn(name = "SAS-fornitore")
         public SicAmmAziende getSicAmmAziende() {
                   return this.sicAmmAziende;
         }
         public void setSicAmmAziende(SicAmmAziende sicAmmAziende) {
                   this.sicAmmAziende = sicAmmAziende;
         }
         @Column(name = "SAS-ordine")
         public Integer getSasOrdine() {
                   return this.sasOrdine;
         }
         public void setSasOrdine(Integer sasOrdine) {
                   this.sasOrdine = sasOrdine;
         }
         @Column(name = "SAS-fornitore")
         public Integer getSasFornitore() {
                   return this.sasFornitore;
         }
         public void setSasFornitore(Integer sasFornitore) {
                   this.sasFornitore = sasFornitore;
         }
         @Temporal(TemporalType.DATE)
         @Column(name = "SAS-data", length = 10)
         public Date getSasData() {
                   return this.sasData;
         }
         public void setSasData(Date sasData) {
                   this.sasData = sasData;
         }
         @Column(name = "SAS-banca")
         public Byte getSasBanca() {
                   return this.sasBanca;
         }
         public void setSasBanca(Byte sasBanca) {
                   this.sasBanca = sasBanca;
         }
         @Column(name = "SAS-importo", precision = 22, scale = 0)
         public Double getSasImporto() {
                   return this.sasImporto;
         }
         public void setSasImporto(Double sasImporto) {
                   this.sasImporto = sasImporto;
         }
         @Column(name = "SAS-scaduto", length = 2)
         public String getSasScaduto() {
                   return this.sasScaduto;
         }
         public void setSasScaduto(String sasScaduto) {
                   this.sasScaduto = sasScaduto;
         }
}
The problem is about the column SAS-fornitore that is present two times:
@Column(name = "SAS-fornitore")
         public Integer getSasFornitore() {
                   return this.sasFornitore;
         }
         public void setSasFornitore(Integer sasFornitore) {
                   this.sasFornitore = sasFornitore;
         }
@ManyToOne(fetch = FetchType.LAZY)
         @JoinColumn(name = "SAS-fornitore")
         public SicAmmAziende getSicAmmAziende() {
                   return this.sicAmmAziende;
         }
         public void setSicAmmAziende(SicAmmAziende sicAmmAziende) {
                   this.sicAmmAziende = sicAmmAziende;
         }
Thanks in advance
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/799035#799035]
Start a new discussion in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128]