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

JDBC Java Discussion :

Suppression d'une occurence


Sujet :

JDBC Java

  1. #1
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut Suppression d'une occurence
    je veux supprimer une occurence de la table BCN dans la base de données

    Hibernate a creé la classe correspondante a la table et voila son 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
    42
    43
    44
    45
    46
    47
    48
    49
    50
    package stt;
     
    import stt.base.BaseBcn;
     
     
     
    public class Bcn extends BaseBcn {
    private static final long serialVersionUID = 1L;
     
    /*[CONSTRUCTOR MARKER BEGIN]*/
    public Bcn () {
    super();
    }
     
    /**
    * Constructor for primary key
    */
    public Bcn (stt.BcnPK id) {
    super(id);
    }
     
    /**
    * Constructor for required fields
    */
    public Bcn (
    stt.BcnPK id,
    java.lang.Integer nfin,
    java.util.Date dtBcn,
    java.lang.Integer cdart,
    java.lang.Integer nbcn,
    java.lang.String cddep,
    java.lang.String logincreateur,
    java.util.Date datecreation,
    java.lang.String loginModificateur,
    java.util.Date dateModification) {
     
    super (
    id,
    nfin,
    dtBcn,
    cdart,
    nbcn,
    cddep,
    logincreateur,
    datecreation,
    loginModificateur,
    dateModification);
    }
     
    /*[CONSTRUCTOR MARKER END]*/
    aussi que la classe BCNPK :

    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
    package stt;
     
    import stt.base.BaseBcnPK;
     
    public class BcnPK extends BaseBcnPK {
    private static final long serialVersionUID = 1L;
     
    /*[CONSTRUCTOR MARKER BEGIN]*/
    public BcnPK () {}
     
    public BcnPK (
    java.lang.String serie,
    java.lang.Integer ndebut,
    java.lang.String idTitre) {
     
    super (
    serie,
    ndebut,
    idTitre);
    }
    /*[CONSTRUCTOR MARKER END]*/
     
     
    }

    j'ai créer une classe SuppressionBcn dont le code est le suivant :



    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
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    import java.util.Date;
    import java.util.Iterator;
     
    import org.hibernate.HibernateException;
    import org.hibernate.Query;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.Configuration;
     
    import stt.Bcn;
    import stt.BcnPK;
    import stt.dao.BcnDAO;
    import stt.dao._RootDAO;
     
    public class SuppressionBcnBean
     
    {
    private String Titre;
    private String serie;
    private int ndeb;
    private int nfin;
    private int qte;
    private int numbcn;
    private Date dtbcn;
    private int cdart;
    private String cddep;
    private String logincre;
    private Date datecre;
    private String loginmod;
    private Date datemod;
    private String msg;
    public SuppressionBcnBean(){}
     
    public String getMsg() {
    return msg;
    }
     
    public void setMsg(String msg) {
    this.msg = msg;
    }
     
    public String getLogincre() {
    return logincre;
    }
     
    public void setLogincre(String logincre) {
    this.logincre = logincre;
    }
     
    public Date getDatecre() {
    return datecre;
    }
     
    public void setDatecre(Date datecre) {
    this.datecre = datecre;
    }
     
    public String getLoginmod() {
    return loginmod;
    }
     
    public void setLoginmod(String loginmod) {
    this.loginmod = loginmod;
    }
     
    public Date getDatemod() {
    return datemod;
    }
     
    public void setDatemod(Date datemod) {
    this.datemod = datemod;
    }
     
    public int getCdart() {
    return cdart;
    }
    public void setCdart(int cdart) {
    this.cdart = cdart;
    }
    public String getCddep() {
    return cddep;
    }
    public void setCddep(String cddep) {
    this.cddep = cddep;
    }
     
     
     
    public String getTitre() {
    return Titre;
    }
    public void setTitre(String titre) {
    Titre = titre;
    }
    public String getSerie() {
    return serie;
    }
    public void setSerie(String serie) {
    this.serie = serie;
    }
    public int getNdeb() {
    return ndeb;
    }
    public void setNdeb(int ndeb) {
    this.ndeb = ndeb;
    }
    public int getNfin() {
    return nfin;
    }
    public void setNfin(int nfin) {
    this.nfin = nfin;
    }
    public int getQte() {
    return qte;
    }
    public void setQte(int qte) {
    this.qte = qte;
    }
    public int getNumbcn() {
    return numbcn;
    }
    public void setNumbcn(int numbcn) {
    this.numbcn = numbcn;
    }
    public Date getDtbcn() {
    return dtbcn;
    }
    public void setDtbcn(Date dtbcn) {
    this.dtbcn = dtbcn;
    }
     
    public String supprimer()
    {
     
    SessionFactory sessionfactory = new Configuration().configure().buildSessionFactory();
    Session session = sessionfactory.openSession();
    try
    {
    BcnDAO dao = new BcnDAO();
    Query q= session.createQuery
    ("from bcn as b where b.Id.idTitre=:idt and b.Id.serie=:s and b.Id.ndebut=: nd and b.nfin=: nf and b.dtBcn=:dt and b.nbcn=:nb");
    q.setString("idt", this.Titre);
    q.setString("s",this.serie);
    q.setInteger("nd",this.ndeb);
    q.setInteger("nf",this.nfin);
    q.setDate("dt",this.dtbcn);
    q.setInteger("nb",this.numbcn);
    Iterator it = q.iterate();
    while (it.hasNext())
    {
    Bcn b = (Bcn) it.next();
    this.cdart=b.getCdart();
    this.cddep=b.getCddep();
    this.logincre=b.getLogincreateur();
    this.datecre=b.getDatecreation();
    this.loginmod=b.getLoginModificateur();
    this.datemod=b.getDateModification();
    }
     
    Bcn bb = new Bcn(new BcnPK(this.serie,this.ndeb,this.Titre),this.nfin,this.dtbcn,this.cdart,this.numbcn,this.cddep,this.logincre,this.datecre,this.loginmod,this.datemod);
    dao.delete(bb);
    this.msg="Suppression effectué";
    return "ok";
     
     
    }
     
    catch(HibernateException e)
    {
    this.msg="Suppression non effectue";
    return "nok";
     
    }
    finally
    {
    session.close();
    }
     
    }
     
    }

    et j'ai conçu une page jsp dont le code est le suivant :



    Code XHTML : 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
    <h1 style="font-size: 30px; font-family: arial; color:blue">SUPPRESSION B.C.N</h1>
     
    <h:panelGrid columns="2" border="5" style="background-color:Orange">
     
    <h:outputText value="Titre"></h:outputText>
    <h:inputText id="title" value="#{suppressionBcnBean.titre}"></h:inputText>
    <h:outputText value="Serie"></h:outputText>
    <h:inputText id="serie" value="#{suppressionBcnBean.serie}"></h:inputText>
    <h:outputText value="Premier N° B.C.N"></h:outputText>
    <h:inputText id="premier" value="#{suppressionBcnBean.ndeb}"></h:inputText>
    <h:outputText value="Dernier N° B.C.N"></h:outputText>
    <h:inputText id="dernier" value="#{suppressionBcnBean.nfin}"></h:inputText>
    <h:outputText value="Quantité"></h:outputText>
    <h:inputText id="quantity" value="#{suppressionBcnBean.qte}"></h:inputText>
    <h:outputText value="Numero B.C.N"></h:outputText>
    <h:inputText id="numbcn" value="#{suppressionBcnBean.numbcn}"></h:inputText>
    <h:outputText value="Date B.C.N"></h:outputText>
    <h:inputText id="datebcn" value="#{suppressionBcnBean.dtbcn}"><f:convertDateTime pattern="yyyy-MM-dd"/></h:inputText><h:message for="datebcn" id="mess1"></h:message>
     
    </h:panelGrid>
     
    <br/><br/>
     
    <h:panelGrid columns="2">
     
    <center>
     
    <h:commandButton value="Supprimer" type="submit"style="font-size: 18px; background-color: Orange" action="#{suppressionBcnBean.supprimer}"></h:commandButton>
     
    <h:commandButton value="Reinitialiser" type="reset" style=" font-size:18px; background-color: Orange"></h:commandButton>
     
    </center>
     
    </h:panelGrid>
     
    <br/>
     
    <h:panelGrid columns="1">
     
    <h:outputText value="#{suppressionBcnBean.msg}"></h:outputText>
     
    </h:panelGrid>
     
    </h:form>
    </center>
    </body>
    </f:view>
    </html>

    le console affiche les erreurs suivantes et la suppression ne s'effectue pas :

    39 [http-8080-1] INFO org.hibernate.cfg.Environment - Hibernate 3.3.0.SP1
    47 [http-8080-1] INFO org.hibernate.cfg.Environment - hibernate.properties not found
    53 [http-8080-1] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
    64 [http-8080-1] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
    210 [http-8080-1] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
    210 [http-8080-1] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
    341 [http-8080-1] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Bcn.hbm.xml
    470 [http-8080-1] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.Bcn -> bcn
    507 [http-8080-1] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Prix.hbm.xml
    532 [http-8080-1] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.Prix -> prix
    532 [http-8080-1] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : StkRvt.hbm.xml
    563 [http-8080-1] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.StkRvt -> stk_rvt
    564 [http-8080-1] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : DefBcn.hbm.xml
    579 [http-8080-1] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.DefBcn -> def_bcn
    579 [http-8080-1] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
    943 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
    943 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
    943 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
    949 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/transtu
    949 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****}
    1271 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 4.1.9-max
    1271 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.10 ( Revision: ${svn.Revision} )
    1306 [http-8080-1] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
    1317 [http-8080-1] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
    1322 [http-8080-1] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    1322 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
    1322 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
    1322 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
    1322 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
    1324 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
    1324 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
    1324 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
    1325 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
    1325 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
    1325 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
    1325 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
    1325 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
    1326 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    1331 [http-8080-1] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
    1331 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
    1331 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
    1331 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
    1331 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
    1331 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
    1331 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
    1331 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
    1345 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
    1345 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
    1346 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
    1346 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
    1434 [http-8080-1] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
    1884 [http-8080-1] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
    que dois je faire comme rectification ?

  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 807
    Points
    48 807
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Bcn bb = new Bcn(new BcnPK(this.serie,this.ndeb,this.Titre),this.nfin,this.dtbcn,this.cdart,this.numbcn,this.cddep,this.logincre,this.datecre,this.loginmod,this.datemod);
    dao.delete(bb);
    Le code en question va tenter de supprimer un objet que t'as obtenu avec un new, il n'existe pas dans hibernate, il n'y a donc rien à supprimer. Il faut supprimer une objet que tu aura obtenu avec un session.load() !

  3. #3
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    merci tchize

    donc je fais :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    Bcn bb = new Bcn(new BcnPK(this.serie,this.ndeb,this.Titre),this.nfin,this.dtbcn,this.cdart,this.numbcn,this.cddep,this.logincre,this.datecre,this.loginmod,this.datemod);
     
    session.load(bb,session);
     
    dao.delete(bb);
    non?

  4. #4
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    j'ai essayé cette solution mé ça marche pas
    le console affiche :
    28 [http-8080-2] INFO org.hibernate.cfg.Environment - Hibernate 3.3.0.SP1
    36 [http-8080-2] INFO org.hibernate.cfg.Environment - hibernate.properties not found
    41 [http-8080-2] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
    52 [http-8080-2] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
    197 [http-8080-2] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
    197 [http-8080-2] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
    424 [http-8080-2] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Bcn.hbm.xml
    758 [http-8080-2] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.Bcn -> bcn
    799 [http-8080-2] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Prix.hbm.xml
    875 [http-8080-2] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.Prix -> prix
    876 [http-8080-2] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : StkRvt.hbm.xml
    903 [http-8080-2] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.StkRvt -> stk_rvt
    903 [http-8080-2] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : DefBcn.hbm.xml
    921 [http-8080-2] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.DefBcn -> def_bcn
    922 [http-8080-2] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
    1310 [http-8080-2] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
    1310 [http-8080-2] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
    1310 [http-8080-2] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
    1317 [http-8080-2] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/transtu?zeroDateTimeBehavior=convertToNull
    1317 [http-8080-2] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****}
    1671 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 4.1.9-max
    1671 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.10 ( Revision: ${svn.Revision} )
    1708 [http-8080-2] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
    1716 [http-8080-2] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
    1724 [http-8080-2] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    1724 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
    1724 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
    1724 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
    1724 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
    1726 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
    1726 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
    1726 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
    1728 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
    1728 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
    1728 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
    1728 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
    1728 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
    1728 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    1734 [http-8080-2] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
    1734 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
    1734 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
    1734 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
    1734 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
    1734 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
    1734 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
    1734 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
    1749 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
    1749 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
    1749 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
    1749 [http-8080-2] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
    1846 [http-8080-2] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
    2393 [http-8080-2] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured

  5. #5
    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 807
    Points
    48 807
    Par défaut
    Citation Envoyé par Emir83 Voir le message
    merci tchize

    donc je fais :

    Bcn bb = new Bcn(new BcnPK(this.serie,this.ndeb,this.Titre),this.nfin,this.dtbcn,this.cdart,this.numbcn,this.cddep,this.logincre,this.datecre,this.loginmod,this.datemod);
    session.load(bb,session);
    dao.delete(bb);

    non?
    Je comprend pas ton code du tout là. Et tes message hibernate sont inutile, ils ne mentionnent que le démarrage d'hibernate. Active au moins le show_sql qu'on voie quelque chose. Le code le plus simple est

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    bb = session.load(BCN.class, id);
    session.delete(bb);
    Après comme je connais pas ton DAO je sais pas quelle soupe tu fais dedans, mais je fronce quand meme du sourcil en te voyant essayer de supprimer un objet que tu viens de créer, ca risque pas d'effacer quoi que ce soit dans la DB.

  6. #6
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    meme cette solution n'a pas marché
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    BcnPK pk = new BcnPK(this.serie,this.ndeb,this.Titre);
                Bcn bb = new Bcn(pk,this.nfin,this.dtbcn,this.cdart,this.numbcn,this.cddep,this.logincre,this.datecre,this.loginmod,this.datemod);
                session.load(bb,pk);
                dao.delete(bb);
                this.msg="Suppression effectué";
                return "ok";

  7. #7
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    voila les classes generées par hibernate
    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
     
    package stt.dao;
     
    import org.hibernate.Session;
     
    import stt.base.BaseBcnDAO;
     
     
    public class BcnDAO extends BaseBcnDAO implements stt.dao.iface.BcnDAO {
     
        public BcnDAO () {}
     
        public BcnDAO (Session session) {
            super(session);
        }
    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
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
     
    package stt.base;
     
    import org.hibernate.Hibernate;
    import org.hibernate.Session;
    import stt.dao.iface.BcnDAO;
    import org.hibernate.criterion.Order;
     
    /**
     * This is an automatically generated DAO class which should not be edited.
     */
    public abstract class BaseBcnDAO extends stt.dao._RootDAO {
     
        public BaseBcnDAO () {}
     
        public BaseBcnDAO (Session session) {
            super(session);
        }
     
        // query name references
     
     
        public static BcnDAO instance;
     
        /**
         * Return a singleton of the DAO
         */
        public static BcnDAO getInstance () {
            if (null == instance) instance = new stt.dao.BcnDAO();
            return instance;
        }
     
        public Class getReferenceClass () {
            return stt.Bcn.class;
        }
     
        public Order getDefaultOrder () {
            return null;
        }
     
        /**
         * Cast the object as a stt.Bcn
         */
        public stt.Bcn cast (Object object) {
            return (stt.Bcn) object;
        }
     
        public stt.Bcn get(stt.BcnPK key)
        {
            return (stt.Bcn) get(getReferenceClass(), key);
        }
     
        public stt.Bcn get(stt.BcnPK key, Session s)
        {
            return (stt.Bcn) get(getReferenceClass(), key, s);
        }
     
        public stt.Bcn load(stt.BcnPK key)
        {
            return (stt.Bcn) load(getReferenceClass(), key);
        }
     
        public stt.Bcn load(stt.BcnPK key, Session s)
        {
            return (stt.Bcn) load(getReferenceClass(), key, s);
        }
     
        public stt.Bcn loadInitialize(stt.BcnPK key, Session s) 
        { 
            stt.Bcn obj = load(key, s); 
            if (!Hibernate.isInitialized(obj)) {
                Hibernate.initialize(obj);
            } 
            return obj; 
        }
     
    /* Generic methods */
     
        /**
         * Return all objects related to the implementation of this DAO with no filter.
         */
        public java.util.List<stt.Bcn> findAll () {
            return super.findAll();
        }
     
        /**
         * Return all objects related to the implementation of this DAO with no filter.
         */
        public java.util.List<stt.Bcn> findAll (Order defaultOrder) {
            return super.findAll(defaultOrder);
        }
     
        /**
         * Return all objects related to the implementation of this DAO with no filter.
         * Use the session given.
         * @param s the Session
         */
        public java.util.List<stt.Bcn> findAll (Session s, Order defaultOrder) {
            return super.findAll(s, defaultOrder);
        }
     
        /**
         * Persist the given transient instance, first assigning a generated identifier. (Or using the current value
         * of the identifier property if the assigned generator is used.) 
         * @param bcn a transient instance of a persistent class 
         * @return the class identifier
         */
        public stt.BcnPK save(stt.Bcn bcn)
        {
            return (stt.BcnPK) super.save(bcn);
        }
     
        /**
         * Persist the given transient instance, first assigning a generated identifier. (Or using the current value
         * of the identifier property if the assigned generator is used.) 
         * Use the Session given.
         * @param bcn a transient instance of a persistent class
         * @param s the Session
         * @return the class identifier
         */
        public stt.BcnPK save(stt.Bcn bcn, Session s)
        {
            return (stt.BcnPK) save((Object) bcn, s);
        }
     
        /**
         * Either save() or update() the given instance, depending upon the value of its identifier property. By default
         * the instance is always saved. This behaviour may be adjusted by specifying an unsaved-value attribute of the
         * identifier property mapping. 
         * @param bcn a transient instance containing new or updated state 
         */
        public void saveOrUpdate(stt.Bcn bcn)
        {
            saveOrUpdate((Object) bcn);
        }
     
        /**
         * Either save() or update() the given instance, depending upon the value of its identifier property. By default the
         * instance is always saved. This behaviour may be adjusted by specifying an unsaved-value attribute of the identifier
         * property mapping. 
         * Use the Session given.
         * @param bcn a transient instance containing new or updated state.
         * @param s the Session.
         */
        public void saveOrUpdate(stt.Bcn bcn, Session s)
        {
            saveOrUpdate((Object) bcn, s);
        }
     
        /**
         * Update the persistent state associated with the given identifier. An exception is thrown if there is a persistent
         * instance with the same identifier in the current session.
         * @param bcn a transient instance containing updated state
         */
        public void update(stt.Bcn bcn) 
        {
            update((Object) bcn);
        }
     
        /**
         * Update the persistent state associated with the given identifier. An exception is thrown if there is a persistent
         * instance with the same identifier in the current session.
         * Use the Session given.
         * @param bcn a transient instance containing updated state
         * @param the Session
         */
        public void update(stt.Bcn bcn, Session s)
        {
            update((Object) bcn, s);
        }
     
        /**
         * Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving
         * Session or a transient instance with an identifier associated with existing persistent state. 
         * @param id the instance ID to be removed
         */
        public void delete(stt.BcnPK id)
        {
            delete((Object) load(id));
        }
     
        /**
         * Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving
         * Session or a transient instance with an identifier associated with existing persistent state. 
         * Use the Session given.
         * @param id the instance ID to be removed
         * @param s the Session
         */
        public void delete(stt.BcnPK id, Session s)
        {
            delete((Object) load(id, s), s);
        }
     
        /**
         * Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving
         * Session or a transient instance with an identifier associated with existing persistent state. 
         * @param bcn the instance to be removed
         */
        public void delete(stt.Bcn bcn)
        {
            delete((Object) bcn);
        }
     
        /**
         * Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving
         * Session or a transient instance with an identifier associated with existing persistent state. 
         * Use the Session given.
         * @param bcn the instance to be removed
         * @param s the Session
         */
        public void delete(stt.Bcn bcn, Session s)
        {
            delete((Object) bcn, s);
        }
     
        /**
         * Re-read the state of the given instance from the underlying database. It is inadvisable to use this to implement
         * long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances.
         * For example 
         * <ul> 
         * <li>where a database trigger alters the object state upon insert or update</li>
         * <li>after executing direct SQL (eg. a mass update) in the same session</li>
         * <li>after inserting a Blob or Clob</li>
         * </ul>
         */
        public void refresh (stt.Bcn bcn, Session s)
        {
            refresh((Object) bcn, s);
        }
    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
     
    package stt.dao;
     
    import org.hibernate.Session;
     
     
    public abstract class _RootDAO extends stt.base._BaseRootDAO {
     
        public _RootDAO () {}
     
        public _RootDAO (Session session) {
            setSession(session);
        }
     
    /*
        If you are using lazy loading, uncomment this
        Somewhere, you should call RootDAO.closeCurrentThreadSessions();
        public void closeSession (Session session) {
            // do nothing here because the session will be closed later
        }
    */
     
    /*
        If you are pulling the SessionFactory from a JNDI tree, uncomment this
        protected SessionFactory getSessionFactory(String configFile) {
            // If you have a single session factory, ignore the configFile parameter
            // Otherwise, you can set a meta attribute under the class node called "config-file" which
            // will be passed in here so you can tell what session factory an individual mapping file
            // belongs to
            return (SessionFactory) new InitialContext().lookup("java:/{SessionFactoryName}");
        }
    */
    }

  8. #8
    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 807
    Points
    48 807
    Par défaut
    Citation Envoyé par Emir83 Voir le message
    meme cette solution n'a pas marché
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
                session.load(bb,pk);
                dao.delete(bb);
                this.msg="Suppression effectué";
                return "ok";
    As-tu lu la documentation de la méthode load(Object,key) ? Elle te dit bien que le chargement se fait dans une instance transiente, donc détachée de la session. Tu ne peux pas supprimer un objet détaché de la session. Je t'ai donné un code correct pour effacer plus haut!

  9. #9
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    quand je fais

    Bcn bb= session.load(Bcn.class ,id);
    dao.delete(bb);


    "id" ne peut pas etre resolu, l'editeur me demande soit de creer une variable locale "id" ou bien une constante"id" or que c'est pas le cas

    tiens compte que la clé primaire de la classe Bcn est composé :


    <hibernate-mapping package="stt">
    <class
    name="Bcn"
    table="bcn"
    >
    <meta attribute="sync-DAO">true</meta>
    <composite-id name="Id" class="BcnPK">
    <key-property
    name="serie"
    column="serie"
    type="string"
    />
    <key-property
    name="ndebut"
    column="n_debut"
    type="integer"
    />
    <key-property
    name="idTitre"
    column="id_titre"
    type="string"
    />
    </composite-id>

    <property
    name="nfin"
    column="n_fin"
    type="integer"
    not-null="true"
    length="10"
    />
    <property
    name="dtBcn"
    column="dt_bcn"
    type="date"
    not-null="true"
    length="10"
    />
    <property
    name="cdart"
    column="cd_art"
    type="integer"
    not-null="true"
    length="10"
    />
    <property
    name="nbcn"
    column="n_bcn"
    type="integer"
    not-null="true"
    length="10"
    />
    <property
    name="cddep"
    column="cd_dep"
    type="string"
    not-null="true"
    length="1"
    />
    <property
    name="logincreateur"
    column="login_createur"
    type="string"
    not-null="true"
    length="10"
    />
    <property
    name="datecreation"
    column="date_creation"
    type="date"
    not-null="true"
    length="10"
    />
    <property
    name="LoginModificateur"
    column="login_modificateur"
    type="string"
    not-null="true"
    length="10"
    />
    <property
    name="DateModification"
    column="date_modification"
    type="date"
    not-null="true"
    length="10"
    />


    </class>
    </hibernate-mapping>





    une autre remarque tchiz :
    je me trouve perdu apres avoir lu ta solution et je me demande
    comment on peut charger une classe sans aucune contraintes sache qu' on va consulter les Bcn qui repond a la clause Where (selon le titre et la periode)

  10. #10
    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 807
    Points
    48 807
    Par défaut
    si les bcn à effacer sont déjà chargé, il suffit de faire un delete sur ces bcn, genre:


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    List<Bcn> maliste = (List<Bcn>)queryPourMesBcn.list();
    for (Bcn bcn : maliste){
      session.delete(bcn);
    }
    Quand à l'id de mon code c'est la clé de ton Bcn, le fait qu'elle soit composite ne change rien. Ta clé composite, normalement, est sérialisable.

  11. #11
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    voila tchiz j'ai rectifié le code de cette façon :

    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
    public String supprimer()
    	{
     
    		SessionFactory sessionfactory = new Configuration().configure().buildSessionFactory();
    		Session session = sessionfactory.openSession();
    		try
    		{    
     
    			Query q= session.createQuery
    			("from Bcn as b where b.Id.idTitre=:idt and b.Id.serie=:s and b.Id.ndebut=: nd and b.nfin=: nf and b.dtBcn=:dt and b.nbcn=:nb");
    			q.setString("idt", this.Titre);
    			q.setString("s",this.serie);
    			q.setInteger("nd",this.ndeb);
    			q.setInteger("nf",this.nfin);
    			q.setDate("dt",this.dtbcn);
    			q.setInteger("nb",this.numbcn);
     
    			List<Bcn> maliste = (List<Bcn>)q.list();
    			for (Bcn bcn : maliste)
    			{
    				  session.delete(bcn);
     
    			}
     
    			this.msg="Suppression effectué";
    			return "ok";
     
     
    		}
     
    		catch(HibernateException e)
    		{
    			this.msg="Suppression non effectue";
    			return "nok";
     
    		}
    		finally
    		{
    			session.close();
    		}
    }
    le probleme persiste encore et je crois que le compilateur dépasse le bloc try l'interface m'affiche toujours "suppression non effectué"

    je suis vraiment desolé je t'ai causé des ennuis !
    je suis encore debutant

  12. #12
    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 807
    Points
    48 807
    Par défaut
    rajoute un

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Transaction tx = session.beginTransaction
    ....
    tx.commit();
    autour de ton code. Assure toi aussi que la liste n'est pas vide et, tant qu'à faire, affiche les requetes sql en mettant dans la config hibernate show_sql à true.

  13. #13
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    j'ai mis true pour le show_sql mais rien ne s'affiche dans le console comme requete sql
    et le probleme en question persiste encore
    et je ne sais pas pourquoi el compilateur s'arrete toujours a ce niveau "Not binding factory to JNDI, no JNDI name configured"??

  14. #14
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    voila ce que affcihe le console :

    [http-8080-1] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
    1268 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
    1268 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
    1268 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
    1277 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/transtu?zeroDateTimeBehavior=convertToNull
    1277 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****}
    1607 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 4.1.9-max
    1608 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.10 ( Revision: ${svn.Revision} )
    1644 [http-8080-1] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
    1654 [http-8080-1] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
    1659 [http-8080-1] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    1659 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
    1659 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
    1659 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
    1659 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
    1661 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
    1662 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
    1662 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
    1664 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
    1664 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
    1664 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
    1664 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
    1664 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
    1664 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    1670 [http-8080-1] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
    1670 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
    1671 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
    1671 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
    1671 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
    1671 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
    1671 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
    1671 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
    1685 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
    1686 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
    1686 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
    1686 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
    1686 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
    1789 [http-8080-1] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
    2368 [http-8080-1] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured

  15. #15
    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 807
    Points
    48 807
    Par défaut
    Citation Envoyé par Emir83 Voir le message
    j'ai mis true pour le show_sql mais rien ne s'affiche dans le console comme requete sql
    Montren nous ton fichier de config
    et le probleme en question persiste encore
    Tu as mis une transaction et confirmé que tu avais bien des éléments dans ta liste?
    et je ne sais pas pourquoi el compilateur s'arrete toujours a ce niveau "Not binding factory to JNDI, no JNDI name configured"??
    Parce qu'il n'a plus rien à dire. Comme le show_sql n'a visiblement pas pris, a part des erreurs éventuelles, il n'aura rien à dire.

  16. #16
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    voila mon cfg:

    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC
    		"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    		"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    	<session-factory>
    		<!-- local connection properties -->
    		<property name="hibernate.connection.url">
    			jdbc:mysql://localhost:3306/transtu?zeroDateTimeBehavior=convertToNull
    		</property>
    		<property name="hibernate.connection.driver_class">
    			com.mysql.jdbc.Driver
    		</property>
    		<property name="hibernate.connection.username">root</property>
    		<property name="hibernate.connection.password" />
    		<!-- property name="hibernate.connection.pool_size"></property -->
    		<!-- dialect for MySQL -->
    		<property name="dialect">
    			org.hibernate.dialect.MySQLDialect
    		</property>
    		<property name="hibernate.show_sql">true</property>
    		<property name="hibernate.transaction.factory_class">
    			org.hibernate.transaction.JDBCTransactionFactory
    		</property>
    		<mapping resource="Bcn.hbm.xml" />
    		<mapping resource="Prix.hbm.xml"/>
    		<mapping resource="StkRvt.hbm.xml"/>
    		<mapping resource="DefBcn.hbm.xml"/>
     
    	</session-factory>
    </hibernate-configuration>
    et voila le code apres l'integration d'une transaction :
    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
     
    public String supprimer()
    	{
     
    		SessionFactory sessionfactory = new Configuration().configure().buildSessionFactory();
    		Session session = sessionfactory.openSession();
    		try
    		{   
                           Transaction tx = session.beginTransaction() ;
    			Query q= session.createQuery
    			("from Bcn as b where b.Id.idTitre=:idt and b.Id.serie=:s and b.Id.ndebut=: nd and b.nfin=: nf and b.dtBcn=:dt and b.nbcn=:nb");
    			q.setString("idt", this.Titre);
    			q.setString("s",this.serie);
    			q.setInteger("nd",this.ndeb);
    			q.setInteger("nf",this.nfin);
    			q.setDate("dt",this.dtbcn);
    			q.setInteger("nb",this.numbcn);
     
    		        List<Bcn> maliste = (List<Bcn>) q.list();
     
                            for (Bcn bcn : maliste)
    			{
    				  session.delete(bcn);
     
    			}
     
     
     
    			tx.commit();
    			this.msg="Suppression effectué";
    			return "ok";
    			}
     
    		catch(HibernateException e)
    		{
    			this.msg="Suppression non effectue";
    			return "nok";
     
    		}
    		finally
    		{
    			session.close();
    		}
     
    	}
    la au niveau de ce ligne" List<Bcn> maliste = (List<Bcn>) q.list();" l'editeur me fait une remarque :"Type safety: Unchecked cast from List to List<Bcn>"
    pour le verification je ne sais comment verifier si la liste est pleine ou non

  17. #17
    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 807
    Points
    48 807
    Par défaut
    Citation Envoyé par Emir83 Voir le message
    je ne sais comment verifier si la liste est pleine ou non
    Sois tu affiche
    System.out.println("Taille de la liste: "+liste.size());

    Soit tu met des messages dans ta boucle

    Soit tu fais du pas à pas.

    Je suis par contre étonné que hibernate ne mentionne pas le chargement de tes classes. D'habitue il indique au démarrage "mapping class Yyyy to table xxxx"

  18. #18
    Nouveau membre du Club
    Inscrit en
    Mars 2007
    Messages
    70
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 70
    Points : 27
    Points
    27
    Par défaut
    si tchiz , hibernate mentionne le chargement de classe :

    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
     
     
    28 [http-8080-1] INFO org.hibernate.cfg.Environment - Hibernate 3.3.0.SP1
    35 [http-8080-1] INFO org.hibernate.cfg.Environment - hibernate.properties not found
    41 [http-8080-1] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
    51 [http-8080-1] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
    198 [http-8080-1] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
    198 [http-8080-1] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
    423 [http-8080-1] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Bcn.hbm.xml
    724 [http-8080-1] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.Bcn -> bcn
    761 [http-8080-1] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Prix.hbm.xml
    790 [http-8080-1] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.Prix -> prix
    790 [http-8080-1] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : StkRvt.hbm.xml
    817 [http-8080-1] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.StkRvt -> stk_rvt
    817 [http-8080-1] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : DefBcn.hbm.xml
    838 [http-8080-1] INFO org.hibernate.cfg.HbmBinder - Mapping class: stt.DefBcn -> def_bcn
    839 [http-8080-1] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
    1210 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
    1210 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
    1210 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
    1217 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/transtu?zeroDateTimeBehavior=convertToNull
    1217 [http-8080-1] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****}
    1555 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 4.1.9-max
    1555 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.10 ( Revision: ${svn.Revision} )
    1596 [http-8080-1] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
    1606 [http-8080-1] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
    1612 [http-8080-1] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    1612 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
    1612 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
    1612 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
    1612 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
    1614 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
    1614 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
    1614 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
    1616 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
    1616 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
    1616 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
    1616 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
    1616 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
    1616 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    1622 [http-8080-1] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
    1622 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
    1622 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
    1622 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
    1622 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
    1622 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
    1622 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
    1622 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
    1635 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
    1637 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
    1637 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
    1637 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
    1637 [http-8080-1] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
    1736 [http-8080-1] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
    2271 [http-8080-1] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured

Discussions similaires

  1. Suppression d'une occurence avec HQl
    Par Emir83 dans le forum JDBC
    Réponses: 0
    Dernier message: 27/12/2009, 17h09
  2. update - modification d'une occurance
    Par starius dans le forum Langage SQL
    Réponses: 5
    Dernier message: 22/04/2004, 12h12
  3. Combler les trous lors d'une suppression dans une table
    Par Billybongjoe dans le forum PostgreSQL
    Réponses: 5
    Dernier message: 08/04/2004, 14h02
  4. Réponses: 6
    Dernier message: 04/03/2004, 09h35
  5. [LG]suppression dans une liste chainée
    Par mister_dsg dans le forum Langage
    Réponses: 9
    Dernier message: 16/12/2003, 21h20

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