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 :

hibernate sql insert vs select


Sujet :

Hibernate Java

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut hibernate sql insert vs select
    Bonjour,

    quand j'affiche le sql fournit par mon system spring hibernate, j'obtient pour le select :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Hibernate: select compoundim_.COMPOUND_ID, compoundim_.COMPOUND_CID as COMPOUND2_0_, compoundim_.COMPOUND_SMILE as COMPOUND3_0_ from COMPOUND compoundim_ where compoundim_.COMPOUND_ID=?
    Mais pour le insert (ou le update):
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Hibernate: update COMPOUND set COMPOUND_CID=?, COMPOUND_SMILE=? where COMPOUND_ID=?
    Est-ce que c'est normal que les tables ne soient pas préfixées de la meme facon ? sinon, ca peut etre du a quoi? En l'occurence, une opération select marche, mais pas le insert/update...

  2. #2
    Membre expérimenté Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Points : 1 371
    Points
    1 371
    Par défaut
    Je pense qu'il prefixe le select tout le temps en cas de jointure.
    Alors que pour l'update, il update table par table donc pas besoin de prefixe.


    Comment ca le select marche mais pas l'update ni le insert??

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    Ouais ca c'est un autre soucis, je ne sais pas pourquoi il me fait pas d'insert dans ma base. J'ai posté un autre sujet a ce propos. Le truc c'est que je pense qu'un log un peu plus parlant m'aiderait, mais étant débutant, je ne sais pas comment résoudre le :

    log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
    log4j:WARN Please initialize the log4j system properly.

    que me donne ma console...

  4. #4
    Membre expérimenté Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Points : 1 371
    Points
    1 371
    Par défaut
    Ahh tu utilises Spring en meme temps!

    Est ce que le user spécifié dans le datasource à les droits en update et insert dans ta base? La est la question.........


    Sinon pour ton
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
    log4j:WARN Please initialize the log4j system properly.
    IL suffit de mettre ce fichier nommé log4j.properties dans WEB-INF/classes avec ce contenu et la tu auras des logs!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.rootLogger=debug, stdout

    Attention la tu risques d'en avoir un bon gros paquet!!
    Si tu veux plus fin faudra que tu configures ton fichier log4j.properties avec plus de finesse.

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    Cool merci !!! effectivement j'obtient une tonne de choses, mais je ne sais toujours pas pourquoi ca entre pas en base...

    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
     
    15:31:44,025  INFO CollectionFactory:73 - JDK 1.4+ collections available
    15:31:44,028  INFO CollectionFactory:76 - Commons Collections 3.x available
    15:31:44,077 DEBUG PluggableSchemaResolver:95 - Loading schema mappings from [META-INF/spring.schemas]
    15:31:44,081 DEBUG PluggableSchemaResolver:101 - Loaded schema mappings: {http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd}
    15:31:44,082 DEBUG PluggableSchemaResolver:95 - Loading schema mappings from [META-INF/spring.schemas]
    15:31:44,085 DEBUG PluggableSchemaResolver:101 - Loaded schema mappings: {http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd}
    15:31:44,094  INFO XmlBeanDefinitionReader:330 - Loading XML bean definitions from class path resource [applicationContext.xml]
    15:31:44,106 DEBUG DefaultDocumentLoader:73 - Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
    15:31:44,181 DEBUG BeansDtdResolver:72 - Found beans DTD [http://www.springframework.org/dtd/spring-beans.dtd] in classpath: spring-beans.dtd
    15:31:44,228 DEBUG DefaultNamespaceHandlerResolver:110 - Loaded mappings [{http://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler, http://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler, http://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler, http://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler, http://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler, http://www.springframework.org/schema/tx=org.springframework.transaction.config.TxNamespaceHandler}]
    15:31:44,235 DEBUG ClassUtils:134 - Class [groovy.lang.GroovyObject] or one of its dependencies is not present: java.lang.ClassNotFoundException: groovy.lang.GroovyObject
    15:31:44,236 DEBUG ClassUtils:134 - Class [org.jruby.IRuby] or one of its dependencies is not present: java.lang.ClassNotFoundException: org.jruby.IRuby
    15:31:44,241 DEBUG ClassUtils:134 - Class [bsh.Interpreter] or one of its dependencies is not present: java.lang.ClassNotFoundException: bsh.Interpreter
    15:31:44,295 DEBUG DefaultBeanDefinitionDocumentReader:84 - Loading bean definitions
    15:31:44,373 DEBUG BeanDefinitionParserDelegate:350 - Neither XML 'id' nor 'name' specified - using generated bean name [org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener#29428e]
    15:31:44,378 DEBUG XmlBeanDefinitionReader:143 - Loaded 5 bean definitions from location pattern [applicationContext.xml]
    15:31:44,380  INFO ClassPathXmlApplicationContext:100 - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=26399554]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,compoundDAO,compound]; root of BeanFactory hierarchy
    15:31:44,390  INFO ClassPathXmlApplicationContext:322 - 5 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=26399554]
    15:31:44,428  INFO ClassPathXmlApplicationContext:473 - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@f7f540]
    15:31:44,431  INFO ClassPathXmlApplicationContext:495 - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@19209ea]
    15:31:44,433  INFO DefaultListableBeanFactory:261 - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,compoundDAO,compound]; root of BeanFactory hierarchy]
    15:31:44,435 DEBUG DefaultListableBeanFactory:137 - Creating shared instance of singleton bean 'dataSource'
    15:31:44,435 DEBUG DefaultListableBeanFactory:346 - Creating instance of bean 'dataSource' with merged definition [Root bean: class [org.springframework.jdbc.datasource.DriverManagerDataSource]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [applicationContext.xml]]
    15:31:44,495 DEBUG DefaultListableBeanFactory:397 - Eagerly caching bean 'dataSource' to allow for resolving potential circular references
    15:31:44,523  INFO DriverManagerDataSource:155 - Loaded JDBC driver: org.hsqldb.jdbcDriver
    15:31:44,525 DEBUG DefaultListableBeanFactory:137 - Creating shared instance of singleton bean 'sessionFactory'
    15:31:44,528 DEBUG DefaultListableBeanFactory:346 - Creating instance of bean 'sessionFactory' with merged definition [Root bean: class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [applicationContext.xml]]
    15:31:44,576 DEBUG DefaultListableBeanFactory:397 - Eagerly caching bean 'sessionFactory' to allow for resolving potential circular references
    15:31:44,577 DEBUG DefaultListableBeanFactory:202 - Returning cached instance of singleton bean 'dataSource'
    15:31:44,579 DEBUG DefaultListableBeanFactory:346 - Creating instance of bean 'org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener#29428e' with merged definition [Root bean: class [org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [applicationContext.xml]]
    15:31:44,632 DEBUG DefaultListableBeanFactory:1116 - Invoking afterPropertiesSet() on bean with name 'sessionFactory'
    15:31:44,661  INFO Environment:500 - Hibernate 3.2.1
    15:31:44,668  INFO Environment:533 - hibernate.properties not found
    15:31:44,676  INFO Environment:667 - Bytecode provider name : cglib
    15:31:44,682  INFO Environment:584 - using JDK 1.4 java.sql.Timestamp handling
    15:31:44,797 DEBUG DTDEntityResolver:38 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
    15:31:44,798 DEBUG DTDEntityResolver:40 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
    15:31:44,799 DEBUG DTDEntityResolver:50 - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
    15:31:44,962  INFO HbmBinder:300 - Mapping class: com.genebio.toxico.compound.CompoundImpl -> COMPOUND
    15:31:44,972 DEBUG HbmBinder:1270 - Mapped property: id -> COMPOUND_ID
    15:31:44,984 DEBUG HbmBinder:1270 - Mapped property: cid -> COMPOUND_CID
    15:31:44,984 DEBUG HbmBinder:1270 - Mapped property: SMILE -> COMPOUND_SMILE
    15:31:44,985  INFO LocalSessionFactoryBean:742 - Building new Hibernate SessionFactory
    15:31:44,986 DEBUG Configuration:1282 - Preparing to build session factory with filters : {}
    15:31:44,986 DEBUG Configuration:1117 - processing extends queue
    15:31:44,987 DEBUG Configuration:1121 - processing collection mappings
    15:31:44,987 DEBUG Configuration:1132 - processing native query and ResultSetMapping mappings
    15:31:44,987 DEBUG Configuration:1140 - processing association property references
    15:31:44,990 DEBUG Configuration:1162 - processing foreign key constraints
    15:31:45,076  INFO ConnectionProviderFactory:72 - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
    15:31:45,087 DEBUG DriverManagerDataSource:289 - Creating new JDBC Connection to [jdbc:hsqldb:file:data/toxico]
    15:31:45,386  INFO SettingsFactory:81 - RDBMS: HSQL Database Engine, version: 1.8.0
    15:31:45,387  INFO SettingsFactory:82 - JDBC driver: HSQL Database Engine Driver, version: 1.8.0
    15:31:45,410  INFO Dialect:151 - Using dialect: org.hibernate.dialect.HSQLDialect
    15:31:45,417  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
    15:31:45,420  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    15:31:45,421  INFO SettingsFactory:134 - Automatic flush during beforeCompletion(): disabled
    15:31:45,421  INFO SettingsFactory:138 - Automatic session close at end of transaction: disabled
    15:31:45,422  INFO SettingsFactory:145 - JDBC batch size: 15
    15:31:45,422  INFO SettingsFactory:148 - JDBC batch updates for versioned data: disabled
    15:31:45,423  INFO SettingsFactory:153 - Scrollable result sets: enabled
    15:31:45,426 DEBUG SettingsFactory:157 - Wrap result sets: disabled
    15:31:45,426  INFO SettingsFactory:161 - JDBC3 getGeneratedKeys(): disabled
    15:31:45,427  INFO SettingsFactory:169 - Connection release mode: on_close
    15:31:45,427  INFO SettingsFactory:196 - Default batch fetch size: 1
    15:31:45,428  INFO SettingsFactory:200 - Generate SQL with comments: disabled
    15:31:45,428  INFO SettingsFactory:204 - Order SQL updates by primary key: disabled
    15:31:45,429  INFO SettingsFactory:369 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    15:31:45,432  INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
    15:31:45,432  INFO SettingsFactory:212 - Query language substitutions: {}
    15:31:45,433  INFO SettingsFactory:217 - JPA-QL strict compliance: disabled
    15:31:45,433  INFO SettingsFactory:222 - Second-level cache: enabled
    15:31:45,435  INFO SettingsFactory:226 - Query cache: disabled
    15:31:45,435  INFO SettingsFactory:356 - Cache provider: org.hibernate.cache.NoCacheProvider
    15:31:45,436  INFO SettingsFactory:241 - Optimize cache for minimal puts: disabled
    15:31:45,436  INFO SettingsFactory:250 - Structured second-level cache entries: disabled
    15:31:45,443  INFO SettingsFactory:270 - Echoing all SQL to stdout
    15:31:45,444  INFO SettingsFactory:277 - Statistics: disabled
    15:31:45,445  INFO SettingsFactory:281 - Deleted entity synthetic identifier rollback: disabled
    15:31:45,446  INFO SettingsFactory:296 - Default entity-mode: pojo
    15:31:45,487  INFO SessionFactoryImpl:161 - building session factory
    15:31:45,488 DEBUG SessionFactoryImpl:173 - Session factory constructed with filter configurations : {}
    15:31:45,489 DEBUG SessionFactoryImpl:177 - instantiating session factory with properties: {java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=/usr/java/jdk1.6.0_01/jre/lib/i386, java.vm.version=1.6.0_01-ea-b03, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=:, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/home/yannmauron/Desktop/test/ToxicoMSJava2, java.runtime.version=1.6.0_01-ea-b03, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/usr/java/jdk1.6.0_01/jre/lib/endorsed, os.arch=i386, java.io.tmpdir=/tmp, line.separator=
    , java.vm.specification.vendor=Sun Microsystems Inc., os.name=Linux, sun.jnu.encoding=UTF-8, java.library.path=/usr/java/jdk1.6.0_01/jre/lib/i386/client:/usr/java/jdk1.6.0_01/jre/lib/i386:/usr/java/jdk1.6.0_01/jre/../lib/i386:/usr/lib/j2se/1.4/jre/lib/i386/client:/usr/lib/j2se/1.4/jre/lib/i386:/usr/lib/j2se/1.4/jre/../lib/i386:/usr/lib/firefox/:/usr/java/packages/lib/i386:/lib:/usr/lib, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compiler, os.version=2.6.17-11-generic, user.home=/home/yannmauron, user.timezone=Europe/Zurich, hibernate.connection.release_mode=on_close, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=UTF-8, java.specification.version=1.6, user.name=yannmauron, java.class.path=/home/yannmauron/Desktop/test/ToxicoMSJava2/bin:/home/yannmauron/Desktop/test/ToxicoMSJava2/lib/cdk-0.99.1.jar:/home/yannmauron/Desktop/test/ToxicoMSJava2/lib/commons-logging-1.1.jar:/home/yannmauron/Desktop/test/ToxicoMSJava2/lib/dom4j-1.6.1.jar:/home/yannmauron/Desktop/test/ToxicoMSJava2/lib/jaxen-1.1-beta-6.jar:/home/yannmauron/Desktop/test/ToxicoMSJava2/lib/junit-4.2.jar:/home/yannmauron/Desktop/test/ToxicoMSJava2/lib/log4j-1.2.14.jar:/home/yannmauron/Desktop/test/ToxicoMSJava2/lib/ProteomeCommons.org-IO.jar:/home/yannmauron/Desktop/test/ToxicoMSJava2/lib/ProteomeCommons.org-IO-T2D.jar:/home/yannmauron/java/hsqldb.jar:/home/yannmauron/java/spring-framework-2.0.2/dist/spring.jar:/home/yannmauron/java/spring-framework-2.0.2/dist/spring-aspects.jar:/home/yannmauron/java/spring-framework-2.0.2/dist/spring-mock.jar:/home/yannmauron/java/spring-framework-2.0.2/dist/spring-src.zip:/home/yannmauron/java/spring-framework-2.0.2/lib/j2ee/jta.jar:/home/yannmauron/java/spring-framework-2.0.2/lib/cglib/cglib-nodep-2.1_3.jar:/home/yannmauron/java/spring-framework-2.0.2/lib/hibernate/jboss-archive-browsing.jar:/home/yannmauron/java/spring-framework-2.0.2/lib/hibernate/hibernate3.jar:/home/yannmauron/java/spring-framework-2.0.2/lib/jakarta-commons/commons-collections.jar:/home/yannmauron/java/spring-framework-2.0.2/lib/log4j/log4j-1.2.14.jar:/home/yannmauron/Desktop/eclipse conf/eclipse/configuration/org.eclipse.osgi/bundles/228/1/.cp/:/home/yannmauron/Desktop/eclipse conf/eclipse/plugins/org.eclipse.jdt.junit_3.2.1.r321_v20060810/junitsupport.jar:/home/yannmauron/Desktop/eclipse conf/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.2.1.r321_v20060721/junitruntime.jar, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=/usr/java/jdk1.6.0_01/jre, hibernate.dialect=org.hibernate.dialect.HSQLDialect, java.specification.vendor=Sun Microsystems Inc., user.language=en, java.vm.info=mixed mode, sharing, java.version=1.6.0_01-ea, java.ext.dirs=/usr/java/jdk1.6.0_01/jre/lib/ext:/usr/java/packages/lib/ext, sun.boot.class.path=/usr/java/jdk1.6.0_01/jre/lib/resources.jar:/usr/java/jdk1.6.0_01/jre/lib/rt.jar:/usr/java/jdk1.6.0_01/jre/lib/sunrsasign.jar:/usr/java/jdk1.6.0_01/jre/lib/jsse.jar:/usr/java/jdk1.6.0_01/jre/lib/jce.jar:/usr/java/jdk1.6.0_01/jre/lib/charsets.jar:/usr/java/jdk1.6.0_01/jre/classes, java.vendor=Sun Microsystems Inc., file.separator=/, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.connection.provider_class=org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=gnome, sun.cpu.isalist=}

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    + ca encore :

    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
     
    15:31:45,839 DEBUG AbstractEntityPersister:2688 - Static SQL for entity: com.genebio.toxico.compound.CompoundImpl
    15:31:45,839 DEBUG AbstractEntityPersister:2693 -  Version select: select COMPOUND_ID from COMPOUND where COMPOUND_ID =?
    15:31:45,840 DEBUG AbstractEntityPersister:2696 -  Snapshot select: select compoundim_.COMPOUND_ID, compoundim_.COMPOUND_CID as COMPOUND2_0_, compoundim_.COMPOUND_SMILE as COMPOUND3_0_ from COMPOUND compoundim_ where compoundim_.COMPOUND_ID=?
    15:31:45,840 DEBUG AbstractEntityPersister:2699 -  Insert 0: insert into COMPOUND (COMPOUND_CID, COMPOUND_SMILE, COMPOUND_ID) values (?, ?, ?)
    15:31:45,843 DEBUG AbstractEntityPersister:2700 -  Update 0: update COMPOUND set COMPOUND_CID=?, COMPOUND_SMILE=? where COMPOUND_ID=?
    15:31:45,843 DEBUG AbstractEntityPersister:2701 -  Delete 0: delete from COMPOUND where COMPOUND_ID=?
    15:31:45,869 DEBUG EntityLoader:79 - Static select for entity com.genebio.toxico.compound.CompoundImpl: select compoundim0_.COMPOUND_ID as COMPOUND1_0_0_, compoundim0_.COMPOUND_CID as COMPOUND2_0_0_, compoundim0_.COMPOUND_SMILE as COMPOUND3_0_0_ from COMPOUND compoundim0_ where compoundim0_.COMPOUND_ID=?
    15:31:45,870 DEBUG EntityLoader:79 - Static select for entity com.genebio.toxico.compound.CompoundImpl: select compoundim0_.COMPOUND_ID as COMPOUND1_0_0_, compoundim0_.COMPOUND_CID as COMPOUND2_0_0_, compoundim0_.COMPOUND_SMILE as COMPOUND3_0_0_ from COMPOUND compoundim0_ where compoundim0_.COMPOUND_ID=?
    15:31:45,871 DEBUG EntityLoader:79 - Static select for entity com.genebio.toxico.compound.CompoundImpl: select compoundim0_.COMPOUND_ID as COMPOUND1_0_0_, compoundim0_.COMPOUND_CID as COMPOUND2_0_0_, compoundim0_.COMPOUND_SMILE as COMPOUND3_0_0_ from COMPOUND compoundim0_ where compoundim0_.COMPOUND_ID=?
    15:31:45,874 DEBUG EntityLoader:79 - Static select for entity com.genebio.toxico.compound.CompoundImpl: select compoundim0_.COMPOUND_ID as COMPOUND1_0_0_, compoundim0_.COMPOUND_CID as COMPOUND2_0_0_, compoundim0_.COMPOUND_SMILE as COMPOUND3_0_0_ from COMPOUND compoundim0_ where compoundim0_.COMPOUND_ID=?
    15:31:45,874 DEBUG EntityLoader:79 - Static select for entity com.genebio.toxico.compound.CompoundImpl: select compoundim0_.COMPOUND_ID as COMPOUND1_0_0_, compoundim0_.COMPOUND_CID as COMPOUND2_0_0_, compoundim0_.COMPOUND_SMILE as COMPOUND3_0_0_ from COMPOUND compoundim0_ where compoundim0_.COMPOUND_ID=?
    15:31:45,884 DEBUG EntityLoader:34 - Static select for action ACTION_MERGE on entity com.genebio.toxico.compound.CompoundImpl: select compoundim0_.COMPOUND_ID as COMPOUND1_0_0_, compoundim0_.COMPOUND_CID as COMPOUND2_0_0_, compoundim0_.COMPOUND_SMILE as COMPOUND3_0_0_ from COMPOUND compoundim0_ where compoundim0_.COMPOUND_ID=?
    15:31:45,886 DEBUG EntityLoader:34 - Static select for action ACTION_REFRESH on entity com.genebio.toxico.compound.CompoundImpl: select compoundim0_.COMPOUND_ID as COMPOUND1_0_0_, compoundim0_.COMPOUND_CID as COMPOUND2_0_0_, compoundim0_.COMPOUND_SMILE as COMPOUND3_0_0_ from COMPOUND compoundim0_ where compoundim0_.COMPOUND_ID=?
    15:31:45,889 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
    15:31:45,892 DEBUG SessionFactoryObjectFactory:76 - registered: ff8081811193985301119398555e0000 (unnamed)
    15:31:45,892  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
    15:31:45,895 DEBUG SessionFactoryImpl:308 - instantiated session factory
    15:31:45,895 DEBUG SessionFactoryImpl:390 - Checking 0 named HQL queries
    15:31:45,896 DEBUG SessionFactoryImpl:410 - Checking 0 named SQL queries
    15:31:45,935 DEBUG DefaultListableBeanFactory:137 - Creating shared instance of singleton bean 'transactionManager'
    15:31:45,935 DEBUG DefaultListableBeanFactory:346 - Creating instance of bean 'transactionManager' with merged definition [Root bean: class [org.springframework.orm.hibernate3.HibernateTransactionManager]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [applicationContext.xml]]
    15:31:45,956 DEBUG DefaultListableBeanFactory:397 - Eagerly caching bean 'transactionManager' to allow for resolving potential circular references
    15:31:45,958 DEBUG DefaultListableBeanFactory:202 - Returning cached instance of singleton bean 'sessionFactory'
    15:31:45,959 DEBUG DefaultListableBeanFactory:1116 - Invoking afterPropertiesSet() on bean with name 'transactionManager'
    15:31:45,980  INFO HibernateTransactionManager:373 - Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@1556d12] of Hibernate SessionFactory for HibernateTransactionManager
    15:31:45,981 DEBUG DefaultListableBeanFactory:137 - Creating shared instance of singleton bean 'compoundDAO'
    15:31:45,984 DEBUG DefaultListableBeanFactory:346 - Creating instance of bean 'compoundDAO' with merged definition [Root bean: class [com.genebio.toxico.compound.CompoundDAOImpl]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [applicationContext.xml]]
    15:31:46,000 DEBUG DefaultListableBeanFactory:397 - Eagerly caching bean 'compoundDAO' to allow for resolving potential circular references
    15:31:46,001 DEBUG DefaultListableBeanFactory:202 - Returning cached instance of singleton bean 'sessionFactory'
    15:31:46,006 DEBUG DefaultListableBeanFactory:1116 - Invoking afterPropertiesSet() on bean with name 'compoundDAO'
    15:31:46,007 DEBUG DefaultListableBeanFactory:137 - Creating shared instance of singleton bean 'compound'
    15:31:46,008 DEBUG DefaultListableBeanFactory:346 - Creating instance of bean 'compound' with merged definition [Root bean: class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [applicationContext.xml]]
    15:31:46,016  INFO DefaultAopProxyFactory:61 - CGLIB2 available: proxyTargetClass feature enabled
    15:31:46,049 DEBUG DefaultListableBeanFactory:397 - Eagerly caching bean 'compound' to allow for resolving potential circular references
    15:31:46,050 DEBUG DefaultListableBeanFactory:202 - Returning cached instance of singleton bean 'transactionManager'
    15:31:46,051 DEBUG DefaultListableBeanFactory:202 - Returning cached instance of singleton bean 'compoundDAO'
    15:31:46,064 DEBUG NameMatchTransactionAttributeSource:108 - Adding transactional method[*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    15:31:46,065 DEBUG NameMatchTransactionAttributeSource:108 - Adding transactional method [find*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly]
    15:31:46,069 DEBUG NameMatchTransactionAttributeSource:108 - Adding transactional method [merge*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    15:31:46,070 DEBUG NameMatchTransactionAttributeSource:108 - Adding transactional method [delete*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    15:31:46,071 DEBUG NameMatchTransactionAttributeSource:108 - Adding transactional method [persist*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    15:31:46,072 DEBUG NameMatchTransactionAttributeSource:108 - Adding transactional method [load*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly]
    15:31:46,073 DEBUG NameMatchTransactionAttributeSource:108 - Adding transactional method [save*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    15:31:46,076 DEBUG DefaultListableBeanFactory:1116 - Invoking afterPropertiesSet() on bean with name 'compound'
    15:31:46,095 DEBUG ProxyFactory:217 - Added new aspect interface: com.genebio.toxico.compound.CompoundDAO
    15:31:46,095 DEBUG ProxyFactory:217 - Added new aspect interface: org.springframework.beans.factory.InitializingBean
    15:31:46,100 DEBUG JdkDynamicAopProxy:110 - Creating JDK dynamic proxy for [com.genebio.toxico.compound.CompoundDAOImpl]
    15:31:46,112 DEBUG ClassPathXmlApplicationContext:239 - Publishing event in context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=26399554]: org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.support.ClassPathXmlApplicationContext: display name [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=26399554]; startup date [Tue Mar 27 15:31:43 CEST 2007]; root of context hierarchy]
    15:31:46,112 DEBUG DefaultListableBeanFactory:202 - Returning cached instance of singleton bean 'compound'
    15:31:46,124 DEBUG HibernateTransactionManager:319 - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@77eaf8]
    15:31:46,126 DEBUG HibernateTransactionManager:347 - Creating new transaction with name [com.genebio.toxico.compound.CompoundDAO.saveCompound]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
    15:31:46,192 DEBUG SessionImpl:220 - opened session at timestamp: 11750023061
    15:31:46,193 DEBUG HibernateTransactionManager:428 - Opened new Session [org.hibernate.impl.SessionImpl@19ec4ed] for Hibernate transaction
    15:31:46,201 DEBUG HibernateTransactionManager:440 - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@19ec4ed]
    15:31:46,232 DEBUG JDBCTransaction:54 - begin
    15:31:46,234 DEBUG ConnectionManager:415 - opening JDBC connection
    15:31:46,235 DEBUG DriverManagerDataSource:289 - Creating new JDBC Connection to [jdbc:hsqldb:file:data/toxico]
    15:31:46,237 DEBUG JDBCTransaction:59 - current autocommit status: true
    15:31:46,237 DEBUG JDBCTransaction:62 - disabling autocommit
    15:31:46,242 DEBUG HibernateTransactionManager:511 - Exposing Hibernate transaction as JDBC transaction [org.hsqldb.jdbc.jdbcConnection@10f41e9]
    15:31:46,245 DEBUG TransactionSynchronizationManager:166 - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@1989b5] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@1556d12] to thread [main]
    15:31:46,245 DEBUG TransactionSynchronizationManager:166 - Bound value [org.springframework.orm.hibernate3.SessionHolder@c3c315] for key [org.hibernate.impl.SessionFactoryImpl@3c9c31] to thread [main]
    15:31:46,246 DEBUG TransactionSynchronizationManager:219 - Initializing transaction synchronization
    15:31:46,250 DEBUG TransactionInterceptor:275 - Getting transaction for [com.genebio.toxico.compound.CompoundDAO.saveCompound]
    15:31:46,252 DEBUG TransactionSynchronizationManager:139 - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@c3c315] for key [org.hibernate.impl.SessionFactoryImpl@3c9c31] bound to thread [main]
    15:31:46,253 DEBUG TransactionSynchronizationManager:139 - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@c3c315] for key [org.hibernate.impl.SessionFactoryImpl@3c9c31] bound to thread [main]
    15:31:46,254 DEBUG HibernateTemplate:359 - Found thread-bound Session for HibernateTemplate
    15:31:46,264 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    15:31:46,265 DEBUG SQL:393 - select compoundim_.COMPOUND_ID, compoundim_.COMPOUND_CID as COMPOUND2_0_, compoundim_.COMPOUND_SMILE as COMPOUND3_0_ from COMPOUND compoundim_ where compoundim_.COMPOUND_ID=?
    Hibernate: select compoundim_.COMPOUND_ID, compoundim_.COMPOUND_CID as COMPOUND2_0_, compoundim_.COMPOUND_SMILE as COMPOUND3_0_ from COMPOUND compoundim_ where compoundim_.COMPOUND_ID=?
    15:31:46,286 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    15:31:46,287 DEBUG AbstractSaveEventListener:113 - generated identifier: 3, using strategy: org.hibernate.id.Assigned
    15:31:46,310 DEBUG HibernateTemplate:383 - Not closing pre-bound Hibernate Session after HibernateTemplate
    15:31:46,311 DEBUG TransactionSynchronizationManager:139 - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@c3c315] for key [org.hibernate.impl.SessionFactoryImpl@3c9c31] bound to thread [main]
    15:31:46,312 DEBUG TransactionSynchronizationManager:139 - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@c3c315] for key [org.hibernate.impl.SessionFactoryImpl@3c9c31] bound to thread [main]
    15:31:46,315 DEBUG HibernateTemplate:359 - Found thread-bound Session for HibernateTemplate
    15:31:46,317 DEBUG AbstractFlushingEventListener:111 - processing flush-time cascades
    15:31:46,319 DEBUG AbstractFlushingEventListener:154 - dirty checking collections
    15:31:46,335 DEBUG AbstractFlushingEventListener:85 - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
    15:31:46,337 DEBUG AbstractFlushingEventListener:91 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
    15:31:46,340 DEBUG Printer:83 - listing entities:
    15:31:46,341 DEBUG Printer:90 - com.genebio.toxico.compound.CompoundImpl{id=3, SMILE=lkjfdg, cid=1234567}
    15:31:46,348 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    15:31:46,348 DEBUG SQL:393 - insert into COMPOUND (COMPOUND_CID, COMPOUND_SMILE, COMPOUND_ID) values (?, ?, ?)
    Hibernate: insert into COMPOUND (COMPOUND_CID, COMPOUND_SMILE, COMPOUND_ID) values (?, ?, ?)
    15:31:46,350 DEBUG AbstractBatcher:44 - Executing batch size: 1
    15:31:46,352 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    15:31:46,352 DEBUG HibernateTemplate:383 - Not closing pre-bound Hibernate Session after HibernateTemplate
    15:31:46,353 DEBUG TransactionInterceptor:305 - Completing transaction for [com.genebio.toxico.compound.CompoundDAO.saveCompound]
    15:31:46,354 DEBUG HibernateTransactionManager:819 - Triggering beforeCommit synchronization
    15:31:46,357 DEBUG HibernateTransactionManager:832 - Triggering beforeCompletion synchronization
    15:31:46,358 DEBUG HibernateTransactionManager:652 - Initiating transaction commit
    15:31:46,358 DEBUG HibernateTransactionManager:558 - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@19ec4ed]
    15:31:46,358 DEBUG JDBCTransaction:103 - commit
    15:31:46,359 DEBUG AbstractFlushingEventListener:111 - processing flush-time cascades
    15:31:46,359 DEBUG AbstractFlushingEventListener:154 - dirty checking collections
    15:31:46,360 DEBUG AbstractFlushingEventListener:85 - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
    15:31:46,360 DEBUG AbstractFlushingEventListener:91 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
    15:31:46,361 DEBUG Printer:83 - listing entities:
    15:31:46,361 DEBUG Printer:90 - com.genebio.toxico.compound.CompoundImpl{id=3, SMILE=lkjfdg, cid=1234567}
    15:31:46,362 DEBUG JDBCTransaction:193 - re-enabling autocommit
    15:31:46,362 DEBUG JDBCTransaction:116 - committed JDBC Connection
    15:31:46,364 DEBUG ConnectionManager:296 - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    15:31:46,364 DEBUG HibernateTransactionManager:845 - Triggering afterCommit synchronization
    15:31:46,365 DEBUG HibernateTransactionManager:861 - Triggering afterCompletion synchronization
    15:31:46,366 DEBUG TransactionSynchronizationManager:272 - Clearing transaction synchronization
    15:31:46,366 DEBUG TransactionSynchronizationManager:190 - Removed value [org.springframework.orm.hibernate3.SessionHolder@c3c315] for key [org.hibernate.impl.SessionFactoryImpl@3c9c31] from thread [main]
    15:31:46,367 DEBUG TransactionSynchronizationManager:190 - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@1989b5] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@1556d12] from thread [main]
    15:31:46,377 DEBUG HibernateTransactionManager:637 - Closing Hibernate Session [org.hibernate.impl.SessionImpl@19ec4ed] after transaction
    15:31:46,377 DEBUG SessionFactoryUtils:781 - Closing Hibernate Session
    15:31:46,378 DEBUG ConnectionManager:435 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    15:31:46,383 DEBUG ConnectionManager:296 - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!

  7. #7
    Membre expérimenté Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Points : 1 371
    Points
    1 371
    Par défaut
    Pourtant dans les logs je vois un

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    insert into COMPOUND (COMPOUND_CID, COMPOUND_SMILE, COMPOUND_ID) values (?, ?, ?)
    Donc il doit te faire l'insert quand meme. Si jamais cette insert la n'est pas en base c'est que lors de l'insert il y a eu un probleme et qu'il a rollbacker.

    Essaye de ne pas prendre la session de spring mais la session hibernate pour faire cette insert et met un try/catch pour récuperer l'erreur complete et donc la raison(peut-etre qu'en faisant ca sur la méthode que Spring appel ca marchera aussi mais vu que je me suis mis à Spring qu'hier je ne suis pas sur).


    Les raisons possibles: pas les droits, il y a des String a la place de number, string trop long, date pas bonne bref a toi de voir de quel type sont "COMPOUND_CID", "COMPOUND_ID" et "COMPOUND_SMILE"!

  8. #8
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    d'ac, merci... je suis tout nouveau aussi du coup... je passe comment par la session hibernate ?

  9. #9
    Membre expérimenté Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Points : 1 371
    Points
    1 371
    Par défaut
    AS tu pris Spring tout de suite ou avait tu configurés Hibernate Avant?

    Tu récupere comment ta session Spring? Via les beans?
    Sinon essaye en premier de mettre un try/catch autour de la "session" Spring => meme si normalement elle est pas très visible (je ne sais pas comment tu as procédé donc je peux pas t'en dire plus).

  10. #10
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    en fait j'ai procédé avec un application context comme ca :

    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
        "http://www.springframework.org/dtd/spring-beans.dtd">
     
    <beans>
     
     <!-- Hibernate data source -->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property>
             <property name="url"><value>jdbc:hsqldb:file:data/toxico</value></property>
            <property name="username"><value>sa</value></property>
            <property name="password"><value></value></property>       
      </bean>
     
     
     <!-- Hibernate SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
         <property name="dataSource"><ref local="dataSource"/></property>
        <property name="mappingResources">
            <list>
                <value>com/genebio/toxico/compound/CompoundImpl.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.connection.autocommit">true</prop>
     
        </props>
        </property>
        		<property name="eventListeners">
    			<map>
    				<entry key="merge">
    					<bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
    				</entry>
    			</map>
    		</property>
    </bean>
     
    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
     
    <bean id="compoundDAO" class="com.genebio.toxico.compound.CompoundDAOImpl">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
     
    	<bean id="compound" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref local="transactionManager"/></property>
    		<property name="target"><ref local="compoundDAO"/></property>
    		<property name="transactionAttributes">
    			<props>
    			<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
       <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
       <prop key="save*">PROPAGATION_REQUIRED</prop>
       <prop key="persist*">PROPAGATION_REQUIRED</prop>
       <prop key="merge*">PROPAGATION_REQUIRED</prop>
       <prop key="delete*">PROPAGATION_REQUIRED</prop> 
    				<prop key="*">PROPAGATION_REQUIRED</prop>
    			</props>
    		</property>
    	</bean>
     
    </beans>
    un fichier de mapping:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
       "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
       "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
     
    <hibernate-mapping package="com.genebio.toxico.compound">
    	<class table="COMPOUND" name="CompoundImpl">
    		<id name="id" type="int" column="COMPOUND_ID"></id>
    		<property name="cid" type="string" column="COMPOUND_CID" />
    		<property name="SMILE" type="string" column="COMPOUND_SMILE" />
    	</class>
     
    </hibernate-mapping>
    et mon dao :
    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
     
    package com.genebio.toxico.compound;
     
    import com.genebio.toxico.compound.Compound;
     
    import org.hibernate.FlushMode;
    import org.hibernate.HibernateException;
    import org.hibernate.Session;
    import org.hibernate.Transaction;
     
    import org.springframework.dao.DataAccessException;
    import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
     
     
    public class CompoundDAOImpl extends HibernateDaoSupport implements CompoundDAO{
     
    	public void saveCompound(CompoundImpl compound) {
     
     
    /*		Session session = this.getSession();
    		System.out.println(session.toString());
    		          try {
    		              session.saveOrUpdate(compound);
    		              session.flush();
    		          } catch (HibernateException e) {
    		              e.printStackTrace();
    		          } finally {
    		              if (session != null) {
    		                  try {
    		                      session.close();
    		                  } catch (HibernateException e) {
    		                      e.printStackTrace();
    		                  }
    		              }
    		          }*/
     
    		getHibernateTemplate().saveOrUpdate(compound);
    	}
     
    	public CompoundImpl getCompound(int id) {
    		return (CompoundImpl) getHibernateTemplate().get(CompoundImpl.class,id);
    	}
     
    	public void removeCompound(int id) {
    		Object compound = getHibernateTemplate().load(CompoundImpl.class, id);
    		getHibernateTemplate().delete(compound);
    	}
    }
    (petite remarque, quand je décoment la partie hibernate du code et commente le template hibernate, j'ai une erreur qui dit que la session est close, mais je crois que je ne l'appele pas bien... peu importe, j'essaie plutot de débuger la version spring...)

    et enfin je test tout ca avec :
    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
     
    package com.genebio.toxico.compound;
     
    import org.hsqldb.Server;
    import org.junit.Before;
    import org.junit.Test;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
     
     
    public class CompoundImplDAOTest {
     
    private CompoundImpl compoundImpl = null;
    private CompoundDAO compoundDAO = null;
    private ApplicationContext ctx = null;
    private Server  hsqlServer = null;
     
     
    	@Test
    	    public void testSaveRecord() throws Exception {
    	        compoundImpl = new CompoundImpl();
    	        compoundImpl.setId(3);
    	        compoundImpl.setCid("1234567");
    	        compoundImpl.setSMILE("lkjfdg");
    	    	String[] paths = {"applicationContext.xml"};
    	    	ctx = new ClassPathXmlApplicationContext(paths);
    	        compoundDAO = (CompoundDAO) ctx.getBean("compound");
    	        compoundDAO.saveCompound(compoundImpl);
             }
     
    /*	@Test
    	public void testloadRecord() throws Exception {
    	    	String[] paths = {"applicationContext.xml"};
    	    	ctx = new ClassPathXmlApplicationContext(paths);
    	        compoundDAO = (CompoundDAO) ctx.getBean("compound");
    			CompoundImpl compound = compoundDAO.getCompound(3);
    			System.out.println(compound.toString());
    	    }*/
     
     
     
    }

  11. #11
    Membre expérimenté Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Points : 1 371
    Points
    1 371
    Par défaut
    Ok j'ai presque tout capté appart pourquoi tu as fait ceci :

    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
    	<bean id="compound" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref local="transactionManager"/></property>
    		<property name="target"><ref local="compoundDAO"/></property>
    		<property name="transactionAttributes">
    			<props>
    			<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
       <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
       <prop key="save*">PROPAGATION_REQUIRED</prop>
       <prop key="persist*">PROPAGATION_REQUIRED</prop>
       <prop key="merge*">PROPAGATION_REQUIRED</prop>
       <prop key="delete*">PROPAGATION_REQUIRED</prop> 
    				<prop key="*">PROPAGATION_REQUIRED</prop>
    			</props>
    		</property>
    	</bean>
    A quoi ca sert? Et pourquoi tu ne recuperes pas plutot ton compoundDAO dans ta classe de test au lieu de compound?? (C'est surement parce que je debute en Spring, donc s'il y a une utilité laquelle est ce? )

    Et est ce que ca marche en faisant ma methode ? (recuperation du DAO dans le test)


    Et sinon avec la version qui est commenté je pense que si tu fais un getSession(true) ca devrait te donner l'erreur;

  12. #12
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    En fait c'est pour gérer ma transaction. effectivement, si je fais ta méthode, il faut que j'appelle directement le DAO, mais sinon, c'est interceptor qui gère la transaction. Par contre, meme avec un getSession(true) je n'ai pas d'erreurs...

Discussions similaires

  1. [SQL] Insert into select(s)
    Par tidou95220 dans le forum SAS Base
    Réponses: 3
    Dernier message: 25/03/2013, 12h14
  2. [SQL] Problème de guillemets dans un INSERT INTO SELECT
    Par Lenezir dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 25/02/2008, 14h21
  3. Insert et select en PL/SQL
    Par Bonjovi51 dans le forum PL/SQL
    Réponses: 19
    Dernier message: 19/10/2006, 14h21
  4. Réponses: 1
    Dernier message: 22/09/2006, 13h56
  5. SQL : syntaxe insert into select
    Par chrislauxerrois dans le forum Access
    Réponses: 15
    Dernier message: 31/07/2006, 16h12

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