IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Hibernate Java Discussion :

Invalid column name


Sujet :

Hibernate Java

  1. #1
    Membre régulier
    Étudiant
    Inscrit en
    Février 2007
    Messages
    202
    Détails du profil
    Informations personnelles :
    Âge : 37

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2007
    Messages : 202
    Points : 97
    Points
    97
    Par défaut Invalid column name
    Bonjour,

    J'ai un problème avec mon mapping bidirectionnel.
    Hibernante pense que c'est un attribut de ma table sql...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Hibernate: select alert0_.id as id1_, alert0_.client as client1_, alert0_.clientId as clientId1_, alert0_.instrument as instrument1_, alert0_.instrumentCode as instrume3_1_, alert0_.isActive as isActive1_, alert0_.isHit as isHit1_, alert0_.name as name1_, alert0_.sendEmail as sendEmail1_, alert0_.sendSMS as sendSMS1_, alert0_.targetPrice as targetPr9_1_ from alert alert0_ where alert0_.instrumentCode=?
    1841 [AWT-EventQueue-0] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 207, SQLState: 42S22
    1841 [AWT-EventQueue-0] ERROR org.hibernate.util.JDBCExceptionReporter  - Invalid column name 'instrument'.
    Voici le code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    package dataObjectLayer;
     
    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.util.List;
    import java.util.Set;
     
    import javax.persistence.*;
     
    @Entity
    @Table(name="instrument")
    public class Instrument {
    	@Id 
    	String code;
    	public String getCode() { return this.code; }
    	public void setCode(String code) { this.code = code; }
     
     
    	Double lastPrice;
    	public Double getLastPrice() { return this.lastPrice; }
    	public void setLastPrice(Double lastPrice) { this.lastPrice = lastPrice; }
     
     
    	Date lastUpdateTime;
    	public Date getLastUpdateTime() {return this.lastUpdateTime; }
    	public void setLastUpdateTime(Date lastUpdateTime) {this.lastUpdateTime = lastUpdateTime; }
     
    	@OneToMany(mappedBy="instrument")
    	List<Alert> alert;
    	public void setAlert(List<Alert> alert) {this.alert = alert;}
    	public List<Alert> getAlert() {return alert;}
     
    	public Instrument() {}
     
    	public Instrument(String code)
    	{
    		this.code = code;
    		this.lastUpdateTime = new Date();
    		this.lastPrice = 0.0;
    	}
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    package dataObjectLayer;
     
    import java.util.GregorianCalendar;
    import javax.persistence.*;
     
    @Entity
    @Table(name="alert")
    public class Alert 
    {
    	@Id 
    	@GeneratedValue 
    	private int id;
    	public int getId() { return this.id; }
     
    	private String clientId;
    	public String getClientId() { return this.clientId;	}
    	public void setClientId(String email) { this.clientId = email;	}
     
    	private String instrumentCode;
    	public String getInstrumentCode() { return this.instrumentCode; }
    	public void setInstrumentCode(String code) { this.instrumentCode = code; }
     
    	private String name;
    	public String getName() { return this.name; }
    	public void setName(String name) { this.name = name; }
     
    	private Double targetPrice;
    	public Double getTargetPrice() {	return this.targetPrice; }
    	public void setTargetPrice(Double price) {	this.targetPrice = price;	}
     
    	private Boolean sendSMS;
    	public Boolean getSendSMS() {	return this.sendSMS; }
    	public void setSendSMS(Boolean sendsms) { this.sendSMS = sendsms; }
     
    	private Boolean sendEmail;
    	public Boolean getSendEmail() {	return this.sendEmail;	}
    	public void setSendEmail(Boolean email) {	this.sendEmail = email;	}
     
    	private Boolean isActive;
    	public Boolean getIsActive() {	return this.isActive;	}
    	public void setIsActive(Boolean active) {	this.isActive = active;	}
     
    	private Boolean isHit;
    	public Boolean getIsHit() {	return this.isHit;	}
    	public void setIsHit(Boolean isHit) {	this.isHit = isHit;	}
     
    	@ManyToOne
    	@JoinColumn(name="client")
    	private Client client;
    	public Client getClient() { return this.client; }
    	public void setClient(Client client) { this.client = client; }
     
    	@ManyToOne
    	@JoinColumn(name="instrument")
    	private Instrument instrument;
    	public Instrument getInstrument() { return this.instrument; }
    	public void setInstrument(Instrument instrument) { this.instrument = instrument; }
     
    	public Alert() {}
     
    	public Alert(String clientId,String instrumentCode,String name, Double targetPrice, Boolean sendSMS, Boolean sendEmail)
    	{
    		this.clientId = clientId;
    		this.instrumentCode = instrumentCode;
    		this.name = name;
    		this.targetPrice = targetPrice;
    		this.sendSMS = sendSMS;
    		this.sendEmail = sendEmail;
    		this.isActive = true;
    		this.isHit = true;
    	}
    }
    Merci de votre aide,
    S

  2. #2
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Points : 48 804
    Points
    48 804
    Par défaut
    en même temps, c'est exactement ce que vous lui avez dit:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    @JoinColumn(name="instrument")
    Pourriez vous nous dire exactement à quoi ressemblent vos tables?

  3. #3
    Membre régulier
    Étudiant
    Inscrit en
    Février 2007
    Messages
    202
    Détails du profil
    Informations personnelles :
    Âge : 37

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2007
    Messages : 202
    Points : 97
    Points
    97
    Par défaut
    Et voilà

    Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    CREATE TABLE instrument(
    	code VARCHAR(10) NOT NULL,
    	lastPrice FLOAT NOT NULL DEFAULT 0,
    	lastUpdateTime DATETIME NOT NULL DEFAULT 0,
    	CONSTRAINT PK_Instrument PRIMARY KEY(code)
    );
     
    CREATE TABLE alert(
    	id INT IDENTITY(1,1) NOT NULL,
    	clientId VARCHAR(128) NOT NULL,
    	instrumentCode VARCHAR(10) NOT NULL,
    	name VARCHAR(50) NOT NULL,
    	targetPrice FLOAT NOT NULL,
    	sendSMS INT NOT NULL DEFAULT 0,
    	sendEmail INT NOT NULL DEFAULT 1,
    	isHit INT NOT NULL DEFAULT 0, -- 0 : No / 1 : Yes
    	isActive INT NOT NULL DEFAULT 1, -- 0 : No / 1 : Yes
    	CONSTRAINT PK_Alert PRIMARY KEY(id),
    	CONSTRAINT FK_Alert_InstrumentCode FOREIGN KEY(instrumentCode) REFERENCES instrument(code),
    	CONSTRAINT FK_Alert_clientId FOREIGN KEY(clientId) REFERENCES client(email),
    );

    Merci

    PS : j'ai le même probleme avec la relation bidirectionnellle Client/Alert mais je ne l'ai pas mise car c'est le même problème qu'avec Instrument / Alert

  4. #4
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Points : 48 804
    Points
    48 804
    Par défaut
    mettez simple
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    @JoinColumn(name="instrumentCode")

  5. #5
    Membre régulier
    Étudiant
    Inscrit en
    Février 2007
    Messages
    202
    Détails du profil
    Informations personnelles :
    Âge : 37

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2007
    Messages : 202
    Points : 97
    Points
    97
    Par défaut
    Merci !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [SQL SRV 2005] problème de case..when --> invalid column name
    Par Kropernic dans le forum Développement
    Réponses: 1
    Dernier message: 12/03/2012, 14h52
  2. Invalid column name ..
    Par lerieure dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 04/10/2010, 11h09
  3. Invalid column name ? Mais le problème vient d'ailleurs !
    Par TigrouMeow dans le forum Hibernate
    Réponses: 7
    Dernier message: 04/01/2007, 18h11
  4. [SQL Server 2K] : Invalid column name
    Par Kyles dans le forum Langage SQL
    Réponses: 4
    Dernier message: 22/05/2006, 12h02
  5. Réponses: 4
    Dernier message: 25/01/2006, 18h25

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo