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 :

Impossible de faire fonctionner Hibernate


Sujet :

Hibernate Java

  1. #1
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Mars 2007
    Messages
    616
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Luxembourg

    Informations forums :
    Inscription : Mars 2007
    Messages : 616
    Points : 556
    Points
    556
    Par défaut Impossible de faire fonctionner Hibernate
    Bonjour,

    Voilà que ça fait plusieurs jours que j'essaye de faire fonctionner Hibernate, mais j'ai toujours des problèmes.

    J'ai lu la FAQ.

    J'ai acheté le livre Hibernate 3.0 (Anthony Patricio)

    J'ai lu le didacticiel fourni avec Hibernate.

    Et j'ai toujours pas pu executer quoi que ce soit avec Hibernate.

    J'ai un problème 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
    .19:07:03,134  INFO Environment:514 - Hibernate 3.2.5
    19:07:03,305  INFO Environment:532 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:mysql:///test, hibernate.show_sql=true, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
    19:07:03,315  INFO Environment:563 - using java.io streams to persist binary types
    19:07:03,325  INFO Environment:681 - Bytecode provider name : cglib
    19:07:03,455  INFO Environment:598 - using JDK 1.4 java.sql.Timestamp handling
    19:07:03,936  INFO Configuration:530 - Reading mappings from resource: cours3/model/Team.hbm.xml
    19:07:04,396 DEBUG DTDEntityResolver:38 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
    19:07:04,396 DEBUG DTDEntityResolver:40 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
    19:07:04,406 DEBUG DTDEntityResolver:50 - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
    19:07:05,378  INFO HbmBinder:300 - Mapping class: cours3.model.Team -> TEAM
    19:07:05,498 DEBUG HbmBinder:1270 - Mapped property: id -> TEAM_ID
    19:07:05,568 DEBUG HbmBinder:1270 - Mapped property: name -> TEAM_NAME
    19:07:05,568 DEBUG HbmBinder:1270 - Mapped property: nbWon -> NB_WON
    19:07:05,578 DEBUG HbmBinder:1270 - Mapped property: nbLost -> NB_LOST
    19:07:05,578 DEBUG HbmBinder:1270 - Mapped property: nbPlayed -> NB_PLAYED
    19:07:06,079 DEBUG HbmBinder:1270 - Mapped property: coach -> COACH_ID
    19:07:06,109 DEBUG HbmBinder:1270 - Mapped property: players
    19:07:06,119 DEBUG HbmBinder:1270 - Mapped property: homeGames
    19:07:06,129 DEBUG HbmBinder:1270 - Mapped property: awayGames
    19:07:06,139  INFO Configuration:530 - Reading mappings from resource: cours3/model/Coach.hbm.xml
    19:07:06,159 DEBUG DTDEntityResolver:38 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
    19:07:06,159 DEBUG DTDEntityResolver:40 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
    19:07:06,189 DEBUG DTDEntityResolver:50 - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
    19:07:06,449  INFO HbmBinder:300 - Mapping class: cours3.model.Coach -> COACH
    19:07:06,459 DEBUG HbmBinder:1270 - Mapped property: id -> COACH_ID
    19:07:06,469 DEBUG HbmBinder:1270 - Mapped property: name -> COACH_NAME
    19:07:06,469  INFO Configuration:530 - Reading mappings from resource: cours3/model/Player.hbm.xml
    19:07:06,479 DEBUG DTDEntityResolver:38 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
    19:07:06,479 DEBUG DTDEntityResolver:40 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
    19:07:06,489 DEBUG DTDEntityResolver:50 - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
    19:07:06,690  INFO HbmBinder:300 - Mapping class: cours3.model.Player -> PLAYER
    19:07:06,700 DEBUG HbmBinder:1270 - Mapped property: id -> PLAYER_ID
    19:07:06,700 DEBUG HbmBinder:1270 - Mapped property: name -> PLAYER_NAME
    19:07:06,700 DEBUG HbmBinder:1270 - Mapped property: number -> PLAYER_NUMBER
    19:07:06,710 DEBUG HbmBinder:1270 - Mapped property: birthday -> BIRTHDAY
    19:07:06,710 DEBUG HbmBinder:1270 - Mapped property: height -> HEIGHT
    19:07:06,710 DEBUG HbmBinder:1270 - Mapped property: weight -> WEIGHT
    19:07:06,720 DEBUG HbmBinder:1270 - Mapped property: hasBeenMvpCount -> select count(*) from GAME g where g.PLAYER_ID = PLAYER_ID
    19:07:06,720 DEBUG HbmBinder:1270 - Mapped property: team -> TEAM_ID
    19:07:06,730  INFO Configuration:530 - Reading mappings from resource: cours3/model/Game.hbm.xml
    19:07:06,740 DEBUG DTDEntityResolver:38 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
    19:07:06,740 DEBUG DTDEntityResolver:40 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
    19:07:06,750 DEBUG DTDEntityResolver:50 - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
    19:07:06,860  INFO HbmBinder:300 - Mapping class: cours3.model.Game -> GAME
    19:07:06,880 DEBUG HbmBinder:1270 - Mapped property: id -> GAME_ID
    19:07:06,910 DEBUG HbmBinder:1270 - Mapped property: awayTeamScore -> AWAY_TEAM_SCORE
    19:07:06,920 DEBUG HbmBinder:1270 - Mapped property: homeTeamScore -> HOME_TEAM_SCORE
    19:07:06,920 DEBUG HbmBinder:1270 - Mapped property: gameDate -> GAME_DATE
    19:07:06,920 DEBUG HbmBinder:1270 - Mapped property: mostValuablePlayer -> PLAYER_ID
    19:07:06,920 DEBUG HbmBinder:1270 - Mapped property: homeTeam -> HOME_TEAM_ID
    19:07:06,930 DEBUG HbmBinder:1270 - Mapped property: awayTeam -> AWAY_TEAM_ID
    19:07:07,100  INFO Dialect:152 - Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
    19:07:07,140 DEBUG Configuration:1285 - Preparing to build session factory with filters : {}
    19:07:07,140 DEBUG Configuration:1120 - processing extends queue
    19:07:07,140 DEBUG Configuration:1124 - processing collection mappings
    19:07:07,140 DEBUG CollectionSecondPass:41 - Second pass for collection: cours3.model.Team.players
    19:07:07,150  INFO HbmBinder:2385 - Mapping collection: cours3.model.Team.players -> PLAYER
    19:07:07,150 DEBUG CollectionSecondPass:57 - Mapped collection key: TEAM_ID, one-to-many: cours3.model.Player
    19:07:07,190 DEBUG CollectionSecondPass:41 - Second pass for collection: cours3.model.Team.homeGames
    19:07:07,190  INFO HbmBinder:2385 - Mapping collection: cours3.model.Team.homeGames -> GAME
    19:07:07,200 DEBUG CollectionSecondPass:57 - Mapped collection key: HOME_TEAM_ID, index: GAME_DATE, one-to-many: cours3.model.Game
    19:07:07,200 DEBUG CollectionSecondPass:41 - Second pass for collection: cours3.model.Team.awayGames
    19:07:07,200  INFO HbmBinder:2385 - Mapping collection: cours3.model.Team.awayGames -> GAME
    19:07:07,210 DEBUG CollectionSecondPass:57 - Mapped collection key: AWAY_TEAM_ID, index: GAME_DATE, one-to-many: cours3.model.Game
    19:07:07,210 DEBUG Configuration:1135 - processing native query and ResultSetMapping mappings
    19:07:07,210 DEBUG Configuration:1143 - processing association property references
    19:07:07,210 DEBUG Configuration:1165 - processing foreign key constraints
    19:07:07,210 DEBUG Configuration:1248 - resolving reference to class: cours3.model.Team
    19:07:07,210 DEBUG Configuration:1248 - resolving reference to class: cours3.model.Team
    19:07:07,220 DEBUG Configuration:1248 - resolving reference to class: cours3.model.Player
    19:07:07,220 DEBUG Configuration:1248 - resolving reference to class: cours3.model.Team
    19:07:07,220 DEBUG Configuration:1248 - resolving reference to class: cours3.model.Coach
    19:07:07,270  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
    19:07:07,280  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
    19:07:07,280  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
    19:07:07,371  INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///test
    19:07:07,381  INFO DriverManagerConnectionProvider:83 - connection properties: {user=root, password=root}
    19:07:07,381 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
    19:07:07,381 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
    19:07:13,239 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:mysql:///test, Isolation Level: 4
    19:07:13,249  INFO SettingsFactory:89 - RDBMS: MySQL, version: 5.0.37-community-nt
    19:07:13,249  INFO SettingsFactory:90 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.5 ( Revision: ${svn.Revision} )
    19:07:13,249 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
    19:07:13,269  INFO Dialect:152 - Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
    19:07:13,299  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
    19:07:13,319  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    19:07:13,319  INFO SettingsFactory:143 - Automatic flush during beforeCompletion(): disabled
    19:07:13,319  INFO SettingsFactory:147 - Automatic session close at end of transaction: disabled
    19:07:13,329  INFO SettingsFactory:162 - Scrollable result sets: enabled
    19:07:13,329 DEBUG SettingsFactory:166 - Wrap result sets: disabled
    19:07:13,329  INFO SettingsFactory:170 - JDBC3 getGeneratedKeys(): enabled
    19:07:13,329  INFO SettingsFactory:178 - Connection release mode: auto
    19:07:13,329  INFO SettingsFactory:202 - Maximum outer join fetch depth: 1
    19:07:13,339  INFO SettingsFactory:205 - Default batch fetch size: 1
    19:07:13,339  INFO SettingsFactory:209 - Generate SQL with comments: disabled
    19:07:13,339  INFO SettingsFactory:213 - Order SQL updates by primary key: disabled
    19:07:13,349  INFO SettingsFactory:217 - Order SQL inserts for batching: disabled
    19:07:13,389  INFO SettingsFactory:386 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    19:07:13,409  INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
    19:07:13,409  INFO SettingsFactory:225 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
    19:07:13,419  INFO SettingsFactory:230 - JPA-QL strict compliance: disabled
    19:07:13,419  INFO SettingsFactory:235 - Second-level cache: enabled
    19:07:13,419  INFO SettingsFactory:239 - Query cache: enabled
    19:07:13,419  INFO SettingsFactory:373 - Cache provider: org.hibernate.cache.EhCacheProvider
    19:07:13,519  INFO SettingsFactory:254 - Optimize cache for minimal puts: disabled
    19:07:13,519  INFO SettingsFactory:259 - Cache region prefix: hibernate.test
    19:07:13,529  INFO SettingsFactory:263 - Structured second-level cache entries: disabled
    19:07:13,529  INFO SettingsFactory:360 - Query cache factory: org.hibernate.cache.StandardQueryCacheFactory
    19:07:13,610 DEBUG SQLExceptionConverterFactory:52 - Using dialect defined converter
    19:07:13,640  INFO SettingsFactory:283 - Echoing all SQL to stdout
    19:07:13,680  INFO SettingsFactory:290 - Statistics: disabled
    19:07:13,680  INFO SettingsFactory:294 - Deleted entity synthetic identifier rollback: disabled
    19:07:13,680  INFO SettingsFactory:309 - Default entity-mode: pojo
    19:07:13,680  INFO SettingsFactory:313 - Named query checking : enabled
    19:07:14,090  INFO SessionFactoryImpl:161 - building session factory
    19:07:14,090 DEBUG SessionFactoryImpl:173 - Session factory constructed with filter configurations : {}
    19:07:14,110 DEBUG SessionFactoryImpl:177 - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=root, hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider, sun.boot.library.path=C:\Program Files\Java\jre1.5.0\bin, java.vm.version=1.5.0-b64, hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, hibernate.cache.use_query_cache=true, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=FR, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate, java.runtime.version=1.5.0-b64, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\Java\jre1.5.0\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\RUS\LOCALS~1\Temp\, line.separator=
    , java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, hibernate.jdbc.batch_versioned_data=true, hibernate.cache.region_prefix=hibernate.test, sun.jnu.encoding=Cp1251, java.library.path=C:\Program Files\Java\jre1.5.0\bin;.;C:\WINDOWS\system32;C:\WINDOWS;c:\Program Files\PHP\;C:\Program Files\Java\jdk1.5.0\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;;, java.specification.name=Java Platform API Specification, java.class.version=49.0, hibernate.connection.pool_size=1, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\RUS, user.timezone=Europe/Paris, java.awt.printerjob=sun.awt.windows.WPrinterJob, java.specification.version=1.5, file.encoding=Cp1252, hibernate.connection.driver_class=com.mysql.jdbc.Driver, user.name=RUS, java.class.path=C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\bin;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\c3p0-0.8.4.5.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\cglib-full-2.0.2.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\commons-beanutils.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\commons-collections-2.1.1.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\commons-digester.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\commons-logging-1.0.4.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\connector.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\dom4j-1.5.2.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\ehcache-1.1.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\hsqldb.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\jaas.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\jakarta-oro.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\jdbc2_0-stdext.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\jta.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\junit-3.8.1.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\log4j-1.2.9.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\odmg-3.0.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\ant-antlr-1.6.2.jar;C:\TRAVAIL\formation\JAVA\Hibenate\TransfertHibernate\lib\antlr-2.7.4.jar;C:\TRAVAIL\formation\eclipse\workspace\hibernate-3.0;C:\hibernate\lib\hibernate3.jar;C:\hibernate\lib\mysql-connector-java-5.1.5-bin.jar;C:\hibernate\lib\hibernate3.jar, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\Program Files\Java\jre1.5.0, hibernate.connection.url=jdbc:mysql:///test, hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect, java.specification.vendor=Sun Microsystems Inc., user.language=fr, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.5.0, hibernate.jdbc.use_streams_for_binary=true, java.ext.dirs=C:\Program Files\Java\jre1.5.0\lib\ext, sun.boot.class.path=C:\Program Files\Java\jre1.5.0\lib\rt.jar;C:\Program Files\Java\jre1.5.0\lib\i18n.jar;C:\Program Files\Java\jre1.5.0\lib\sunrsasign.jar;C:\Program Files\Java\jre1.5.0\lib\jsse.jar;C:\Program Files\Java\jre1.5.0\lib\jce.jar;C:\Program Files\Java\jre1.5.0\lib\charsets.jar;C:\Program Files\Java\jre1.5.0\classes, java.vendor=Sun Microsystems Inc., hibernate.jdbc.batch_size=0, file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.hbm2ddl.auto=create-drop, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, hibernate.max_fetch_depth=1, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86}
    E
    Time: 11,907
    There was 1 error:
    1) testFormula(cours2.test.FormulaTest)java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.<init>()V from class org.hibernate.cache.EhCacheProvider
    	at org.hibernate.cache.EhCacheProvider.start(EhCacheProvider.java:124)
    	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:183)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
    	at test.TestCase.buildSessionFactory(TestCase.java:86)
    	at test.TestCase.setUp(TestCase.java:102)
    	at cours2.test.FormulaTest.main(FormulaTest.java:44)
     
    FAILURES!!!
    Tests run: 1,  Failures: 0,  Errors: 1
    Les exemples des classes sont pris dans le livre
    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
    package cours2.test;
     
    import junit.framework.Test;
    import junit.framework.TestSuite;
    import junit.textui.TestRunner;
     
    import org.hibernate.Session;
    import org.hibernate.Transaction;
     
    import cours3.model.Player;
     
    /**
     * @author Anthony
     *
     * Simple formula test 
     */
    public class FormulaTest extends TestCaseWithData{
     
     
    	public void testFormula() throws Exception  {
    		initData();
    		Session session = openSession();
    		Transaction tx = null ;
    		tx = session.beginTransaction();
    		Player player = (Player)session.get(Player.class, new Long(1));
    		assertEquals(player.getHasBeenMvpCount(),1);
    		tx.commit();
    		session.close();
    	}
     
    	public FormulaTest(String arg0) {
    		super(arg0);
    	}
     
    	public String[] getMappings() {
    		return new String[] {"cours3/model/Team.hbm.xml","cours3/model/Coach.hbm.xml","cours3/model/Player.hbm.xml","cours3/model/Game.hbm.xml" };
    	}
     
    	public static Test suite() {
    		return new TestSuite(FormulaTest.class);
    	}
     
    	public static void main(String[] args) throws Exception {
    		TestRunner.run( suite() );
    	}
    }
    J'ai essayé de faire fonctionner sous Eclipse, j'ai rajouté tous les JARs nécessaires.

    Ma BD est MySQL qui tourne très bien avec les scripts PHP sur ma machine.




    Pourquoi ça marche pas

  2. #2
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Mars 2007
    Messages
    616
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Luxembourg

    Informations forums :
    Inscription : Mars 2007
    Messages : 616
    Points : 556
    Points
    556
    Par défaut
    Apparemment j'ai trouvé pourquoi ca ne marchais pas. Par ce que ehcache 1.1avait des constructeurs private. alors que le package Hibernate n'était pas compris avec les exemples du livre.

    Alors j'ai remplacé tous les packages par ceux qui allaient avec hibernate3.

    Maitenant j'ai un problème 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
    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
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    11:09:24,101 DEBUG SQL:401 - insert into GAME (AWAY_TEAM_SCORE, HOME_TEAM_SCORE, GAME_DATE, PLAYER_ID, HOME_TEAM_ID, AWAY_TEAM_ID, GAME_ID) values (?, ?, ?, ?, ?, ?, ?)
    Hibernate: insert into GAME (AWAY_TEAM_SCORE, HOME_TEAM_SCORE, GAME_DATE, PLAYER_ID, HOME_TEAM_ID, AWAY_TEAM_ID, GAME_ID) values (?, ?, ?, ?, ?, ?, ?)
    11:09:24,111 DEBUG AbstractEntityPersister:1992 - Dehydrating entity: [cours3.model.Game#5]
    11:09:24,111 DEBUG IntegerType:133 - binding '0' to parameter: 1
    11:09:24,111 DEBUG IntegerType:133 - binding '4' to parameter: 2
    11:09:24,111 DEBUG TimestampType:126 - binding null to parameter: 3
    11:09:24,111 DEBUG LongType:133 - binding '2' to parameter: 4
    11:09:24,121 DEBUG LongType:133 - binding '2' to parameter: 5
    11:09:24,131 DEBUG LongType:133 - binding '3' to parameter: 6
    11:09:24,131 DEBUG LongType:133 - binding '5' to parameter: 7
    11:09:24,131 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [GAME]
    11:09:24,201 DEBUG AbstractEntityPersister:2204 - Inserting entity: [cours3.model.Game#6]
    11:09:24,201 DEBUG AbstractBatcher:226 - reusing prepared statement
    11:09:24,201 DEBUG SQL:401 - insert into GAME (AWAY_TEAM_SCORE, HOME_TEAM_SCORE, GAME_DATE, PLAYER_ID, HOME_TEAM_ID, AWAY_TEAM_ID, GAME_ID) values (?, ?, ?, ?, ?, ?, ?)
    Hibernate: insert into GAME (AWAY_TEAM_SCORE, HOME_TEAM_SCORE, GAME_DATE, PLAYER_ID, HOME_TEAM_ID, AWAY_TEAM_ID, GAME_ID) values (?, ?, ?, ?, ?, ?, ?)
    11:09:24,211 DEBUG AbstractEntityPersister:1992 - Dehydrating entity: [cours3.model.Game#6]
    11:09:24,211 DEBUG IntegerType:133 - binding '0' to parameter: 1
    11:09:24,221 DEBUG IntegerType:133 - binding '1' to parameter: 2
    11:09:24,271 DEBUG TimestampType:126 - binding null to parameter: 3
    11:09:24,271 DEBUG LongType:133 - binding '3' to parameter: 4
    11:09:24,281 DEBUG LongType:133 - binding '3' to parameter: 5
    11:09:24,281 DEBUG LongType:133 - binding '2' to parameter: 6
    11:09:24,281 DEBUG LongType:133 - binding '6' to parameter: 7
    11:09:24,281 DEBUG AbstractBatcher:374 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    11:09:24,291 DEBUG AbstractBatcher:533 - closing statement
    11:09:24,291 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [PLAYER]
    11:09:24,301 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [GAME]
    11:09:24,301 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [GAME]
    11:09:24,301 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [PLAYER]
    11:09:24,301 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [GAME]
    11:09:24,301 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [GAME]
    11:09:24,311 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [PLAYER]
    11:09:24,311 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [GAME]
    11:09:24,311 DEBUG UpdateTimestampsCache:50 - Pre-invalidating space [GAME]
    11:09:24,311 DEBUG ConnectionManager:478 - registering flush end
    11:09:24,321 DEBUG AbstractFlushingEventListener:321 - post flush
    11:09:24,331 DEBUG JDBCContext:201 - before transaction completion
    11:09:24,331 DEBUG SessionImpl:393 - before transaction completion
    11:09:24,381 DEBUG JDBCTransaction:116 - committed JDBC Connection
    11:09:24,381 DEBUG JDBCContext:215 - after transaction completion
    11:09:24,381 DEBUG ConnectionManager:404 - aggressively releasing JDBC connection
    11:09:24,381 DEBUG ConnectionManager:441 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    11:09:24,391 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
    11:09:24,391 DEBUG SessionImpl:422 - after transaction completion
    11:09:24,391 DEBUG UpdateTimestampsCache:65 - Invalidating space [COACH], timestamp: 4906187834945536
    11:09:24,391 DEBUG UpdateTimestampsCache:65 - Invalidating space [TEAM], timestamp: 4906187834945537
    11:09:24,601 DEBUG UpdateTimestampsCache:65 - Invalidating space [PLAYER], timestamp: 4906187835805696
    11:09:24,601 DEBUG UpdateTimestampsCache:65 - Invalidating space [COACH], timestamp: 4906187835805697
    11:09:24,601 DEBUG UpdateTimestampsCache:65 - Invalidating space [TEAM], timestamp: 4906187835805698
    11:09:24,601 DEBUG UpdateTimestampsCache:65 - Invalidating space [PLAYER], timestamp: 4906187835805699
    11:09:24,601 DEBUG UpdateTimestampsCache:65 - Invalidating space [COACH], timestamp: 4906187835805700
    11:09:24,641 DEBUG UpdateTimestampsCache:65 - Invalidating space [TEAM], timestamp: 4906187835969536
    11:09:24,641 DEBUG UpdateTimestampsCache:65 - Invalidating space [PLAYER], timestamp: 4906187835969537
    11:09:24,641 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187835969538
    11:09:24,641 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187835969539
    11:09:24,651 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836010496
    11:09:24,651 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836010497
    11:09:24,651 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836010498
    11:09:24,661 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836010499
    11:09:24,661 DEBUG UpdateTimestampsCache:65 - Invalidating space [PLAYER], timestamp: 4906187836051456
    11:09:24,661 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836051457
    11:09:24,661 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836051458
    11:09:24,671 DEBUG UpdateTimestampsCache:65 - Invalidating space [PLAYER], timestamp: 4906187836092416
    11:09:24,671 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836092417
    11:09:24,671 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836092418
    11:09:24,671 DEBUG UpdateTimestampsCache:65 - Invalidating space [PLAYER], timestamp: 4906187836092419
    11:09:24,751 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836420096
    11:09:24,751 DEBUG UpdateTimestampsCache:65 - Invalidating space [GAME], timestamp: 4906187836420097
    11:09:24,761 DEBUG SessionImpl:273 - closing session
    11:09:24,761 DEBUG ConnectionManager:375 - connection already null in cleanup : no action
    11:09:24,892 DEBUG SessionImpl:220 - opened session at timestamp: 4906187836997632
    11:09:24,902 DEBUG JDBCTransaction:54 - begin
    11:09:24,902 DEBUG ConnectionManager:421 - opening JDBC connection
    11:09:24,902 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
    11:09:24,902 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
    11:09:24,902 DEBUG JDBCTransaction:59 - current autocommit status: false
    11:09:24,902 DEBUG JDBCContext:210 - after transaction begin
    11:09:24,952 DEBUG DefaultLoadEventListener:171 - loading entity: [cours3.model.Player#1]
    11:09:24,952 DEBUG DefaultLoadEventListener:332 - attempting to resolve: [cours3.model.Player#1]
    11:09:24,962 DEBUG DefaultLoadEventListener:369 - object not resolved in any cache: [cours3.model.Player#1]
    11:09:24,962 DEBUG AbstractEntityPersister:3037 - Fetching entity: [cours3.model.Player#1]
    11:09:24,962 DEBUG Loader:1852 - loading entity: [cours3.model.Player#1]
    11:09:25,102 DEBUG AbstractBatcher:366 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    11:09:25,102 DEBUG SQL:401 - select player0_.PLAYER_ID as PLAYER1_2_0_, player0_.PLAYER_NAME as PLAYER2_2_0_, player0_.PLAYER_NUMBER as PLAYER3_2_0_, player0_.BIRTHDAY as BIRTHDAY2_0_, player0_.HEIGHT as HEIGHT2_0_, player0_.WEIGHT as WEIGHT2_0_, player0_.TEAM_ID as TEAM7_2_0_, select count(*) from GAME g where g.PLAYER_ID = player0_.PLAYER_ID as formula0_0_ from PLAYER player0_ where player0_.PLAYER_ID=?
    Hibernate: select player0_.PLAYER_ID as PLAYER1_2_0_, player0_.PLAYER_NAME as PLAYER2_2_0_, player0_.PLAYER_NUMBER as PLAYER3_2_0_, player0_.BIRTHDAY as BIRTHDAY2_0_, player0_.HEIGHT as HEIGHT2_0_, player0_.WEIGHT as WEIGHT2_0_, player0_.TEAM_ID as TEAM7_2_0_, select count(*) from GAME g where g.PLAYER_ID = player0_.PLAYER_ID as formula0_0_ from PLAYER player0_ where player0_.PLAYER_ID=?
    11:09:25,102 DEBUG AbstractBatcher:484 - preparing statement
    11:09:25,112 DEBUG LongType:133 - binding '1' to parameter: 1
    11:09:25,182 DEBUG AbstractBatcher:374 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    11:09:25,182 DEBUG AbstractBatcher:533 - closing statement
    11:09:25,352 DEBUG JDBCExceptionReporter:69 - could not load an entity: [cours3.model.Player#1] [select player0_.PLAYER_ID as PLAYER1_2_0_, player0_.PLAYER_NAME as PLAYER2_2_0_, player0_.PLAYER_NUMBER as PLAYER3_2_0_, player0_.BIRTHDAY as BIRTHDAY2_0_, player0_.HEIGHT as HEIGHT2_0_, player0_.WEIGHT as WEIGHT2_0_, player0_.TEAM_ID as TEAM7_2_0_, select count(*) from GAME g where g.PLAYER_ID = player0_.PLAYER_ID as formula0_0_ from PLAYER player0_ where player0_.PLAYER_ID=?]
    com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from GAME g where g.PLAYER_ID = player0_.PLAYER_ID as formula0_0' at line 1
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1027)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
    	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
    	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
    	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
    	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
    	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1888)
    	at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
    	at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
    	at org.hibernate.loader.Loader.doQuery(Loader.java:674)
    	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
    	at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
    	at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
    	at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
    	at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
    	at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
    	at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
    	at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
    	at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
    	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
    	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
    	at cours2.test.FormulaTest.testFormula(FormulaTest.java:25)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at junit.framework.TestCase.runTest(TestCase.java:154)
    	at test.TestCase.runTest(TestCase.java:109)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at junit.textui.TestRunner.doRun(TestRunner.java:116)
    	at junit.textui.TestRunner.doRun(TestRunner.java:109)
    	at junit.textui.TestRunner.run(TestRunner.java:72)
    	at cours2.test.FormulaTest.main(FormulaTest.java:44)
    11:09:25,362  WARN JDBCExceptionReporter:77 - SQL Error: 1064, SQLState: 42000
    11:09:25,462 ERROR JDBCExceptionReporter:78 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from GAME g where g.PLAYER_ID = player0_.PLAYER_ID as formula0_0' at line 1
    11:09:25,472  INFO DefaultLoadEventListener:111 - Error performing load command
    org.hibernate.exception.SQLGrammarException: could not load an entity: [cours3.model.Player#1]
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    	at org.hibernate.loader.Loader.loadEntity(Loader.java:1874)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
    	at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
    	at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
    	at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
    	at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
    	at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
    	at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
    	at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
    	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
    	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
    	at cours2.test.FormulaTest.testFormula(FormulaTest.java:25)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at junit.framework.TestCase.runTest(TestCase.java:154)
    	at test.TestCase.runTest(TestCase.java:109)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at junit.textui.TestRunner.doRun(TestRunner.java:116)
    	at junit.textui.TestRunner.doRun(TestRunner.java:109)
    	at junit.textui.TestRunner.run(TestRunner.java:72)
    	at cours2.test.FormulaTest.main(FormulaTest.java:44)
    Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from GAME g where g.PLAYER_ID = player0_.PLAYER_ID as formula0_0' at line 1
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1027)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
    	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
    	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
    	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
    	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
    	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1888)
    	at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
    	at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
    	at org.hibernate.loader.Loader.doQuery(Loader.java:674)
    	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
    	at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
    	... 29 more
    org.hibernate.exception.SQLGrammarException: could not load an entity: [cours3.model.Player#1]
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    	at org.hibernate.loader.Loader.loadEntity(Loader.java:1874)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
    	at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
    	at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
    	at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
    	at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
    	at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
    	at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
    	at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
    	at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
    	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
    	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
    	at cours2.test.FormulaTest.testFormula(FormulaTest.java:25)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at junit.framework.TestCase.runTest(TestCase.java:154)
    	at test.TestCase.runTest(TestCase.java:109)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at junit.textui.TestRunner.doRun(TestRunner.java:116)
    	at junit.textui.TestRunner.doRun(TestRunner.java:109)
    	at junit.textui.TestRunner.run(TestRunner.java:72)
    	at cours2.test.FormulaTest.main(FormulaTest.java:44)
    Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from GAME g where g.PLAYER_ID = player0_.PLAYER_ID as formula0_0' at line 1
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1027)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
    	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
    	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
    	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
    	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
    	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1888)
    	at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
    	at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
    	at org.hibernate.loader.Loader.doQuery(Loader.java:674)
    	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
    	at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
    	... 29 more
    11:09:27,005 DEBUG SessionImpl:273 - closing session
    11:09:27,005 DEBUG ConnectionManager:380 - performing cleanup
    11:09:27,015 DEBUG ConnectionManager:441 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    11:09:27,015 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
    11:09:27,015  INFO SessionFactoryImpl:769 - closing
    11:09:27,035  INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:mysql:///test
    11:09:27,045  INFO SchemaExport:154 - Running hbm2ddl schema export
    11:09:27,055 DEBUG SchemaExport:170 - import file not found: /import.sql
    11:09:27,055  INFO SchemaExport:179 - exporting generated schema to database
    11:09:27,055 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
    11:09:27,335 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
    11:09:28,016 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:mysql:///test, Isolation Level: 4
    11:09:28,016 DEBUG SchemaExport:303 - alter table GAME drop foreign key FK2143F2F76A6C24
    J'ai essayé tous les dialects:
    MySQLDialect
    MySQL5Dialect
    MySQLInnoDBDialect
    MySQL5InnoDBDialect
    MySQLMyISAMDialect
    et j'ai toujours un problème de syntaxe

    Apparemment Hibernate ne met pas les parenthèses dans les sous-requetes et devraient s'écrire comme ça:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    select 
    player0_.PLAYER_ID as PLAYER1_2_0_, 
    player0_.PLAYER_NAME as PLAYER2_2_0_, 
    player0_.PLAYER_NUMBER as PLAYER3_2_0_, 
    player0_.BIRTHDAY as BIRTHDAY2_0_, 
    player0_.HEIGHT as HEIGHT2_0_, 
    player0_.WEIGHT as WEIGHT2_0_, 
    player0_.TEAM_ID as TEAM7_2_0_, 
    (select count(*) 
    from GAME g where g.PLAYER_ID = player0_.PLAYER_ID) as formula0_0_ 
    from PLAYER player0_ where player0_.PLAYER_ID=?
    Est ce que le problème vient bien d'Hibernate ou du programme JAVA?

  3. #3
    Membre régulier
    Inscrit en
    Février 2005
    Messages
    122
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 122
    Points : 110
    Points
    110
    Par défaut
    Salut,

    Poste le mapping et la requête HQL correspondante pour qu'on puisse t'aider.

Discussions similaires

  1. [Requête] Impossible de faire fonctionner !
    Par Nesta92 dans le forum Requêtes et SQL.
    Réponses: 3
    Dernier message: 17/04/2007, 09h38
  2. Réponses: 5
    Dernier message: 05/12/2006, 23h57
  3. impossible de faire fonctionner le gridlayout
    Par oceane751 dans le forum AWT/Swing
    Réponses: 6
    Dernier message: 12/06/2006, 10h42
  4. Réponses: 5
    Dernier message: 22/03/2006, 10h39
  5. impossible de faire fonctionner phppgadmin et pgdmin3
    Par le_ben dans le forum PostgreSQL
    Réponses: 6
    Dernier message: 09/12/2004, 14h27

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