lele_vader 20 de set. de 2012
O framework de persistência não tem diferenciação em qual local você o roda.
A diferença é que na plataforma web você não precisaria criar o EntityManager e no desktop sim.
Essa é a única diferença que vejo.
Mostre o erro que ocorre na plataforma desktop
javaimae 21 de set. de 2012
Obrigado pela ajuda o que você disse parece fazer sentido não projeto Web eu pego o EntityManager com o @PersistenceContext já no desktop eu instancio na mão, realmente esse parece ser a única diferença. Vou postar o erro
[ EL Info ] : 2012-09-21 08 : 13 : 23.455 – ServerSession ( 1345122 ) – EclipseLink , version : Eclipse Persistence Services - 2.0.2 . v20100323 - r6872
[ EL Severe ] : 2012-09-21 08 : 13 : 24.251 – ServerSession ( 1345122 ) – Local Exception Stack :
Exception [ EclipseLink -8025 ] ( Eclipse Persistence Services - 2.0.2 . v20100323 - r6872 ) : org . eclipse . persistence . exceptions . JPQLException
Exception Description : Syntax error parsing the query [ usuarios . findAllOrderByName : SELECT u FROM usuarios u order by upper ( u . nome )], line 1 , column 36 : unexpected token [ upper ].
Internal Exception : NoViableAltException ( 74 != [ 1328 : 1 : orderByItem returns [ Object node ] : ( n = stateFieldPathExpression ( a = ASC | d = DESC | ) | i = IDENT ( a = ASC | d = DESC | ) );])
Exception in thread “ main ” javax . persistence . PersistenceException : Exception [ EclipseLink -8025 ] ( Eclipse Persistence Services - 2.0.2 . v20100323 - r6872 ) : org . eclipse . persistence . exceptions . JPQLException
Exception Description : Syntax error parsing the query [ usuarios . findAllOrderByName : SELECT u FROM usuarios u order by upper ( u . nome )], line 1 , column 36 : unexpected token [ upper ].
Internal Exception : NoViableAltException ( 74 != [ 1328 : 1 : orderByItem returns [ Object node ] : ( n = stateFieldPathExpression ( a = ASC | d = DESC | ) | i = IDENT ( a = ASC | d = DESC | ) );])
at org . eclipse . persistence . exceptions . JPQLException . unexpectedToken ( JPQLException . java : 372 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . handleRecognitionException ( JPQLParser . java : 319 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . addError ( JPQLParser . java : 245 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . reportError ( JPQLParser . java : 362 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . orderByItem ( JPQLParser . java : 13605 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . orderByClause ( JPQLParser . java : 13356 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . selectStatement ( JPQLParser . java : 434 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . document ( JPQLParser . java : 276 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . parse ( JPQLParser . java : 133 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . buildParseTree ( JPQLParser . java : 94 )
at org . eclipse . persistence . internal . jpa . EJBQueryImpl . buildEJBQLDatabaseQuery ( EJBQueryImpl . java : 198 )
at org . eclipse . persistence . internal . jpa . JPAQuery . processJPQLQuery ( JPAQuery . java : 106 )
at org . eclipse . persistence . internal . jpa . JPAQuery . prepare ( JPAQuery . java : 90 )
at org . eclipse . persistence . queries . DatabaseQuery . checkPrepare ( DatabaseQuery . java : 464 )
at org . eclipse . persistence . queries . DatabaseQuery . checkPrepare ( DatabaseQuery . java : 430 )
at org . eclipse . persistence . internal . sessions . AbstractSession . processJPAQueries ( AbstractSession . java : 1747 )
at org . eclipse . persistence . internal . sessions . DatabaseSessionImpl . initializeDescriptors ( DatabaseSessionImpl . java : 409 )
at org . eclipse . persistence . internal . sessions . DatabaseSessionImpl . postConnectDatasource ( DatabaseSessionImpl . java : 671 )
at org . eclipse . persistence . internal . sessions . DatabaseSessionImpl . loginAndDetectDatasource ( DatabaseSessionImpl . java : 620 )
at org . eclipse . persistence . internal . jpa . EntityManagerFactoryProvider . login ( EntityManagerFactoryProvider . java : 228 )
at org . eclipse . persistence . internal . jpa . EntityManagerSetupImpl . deploy ( EntityManagerSetupImpl . java : 397 )
at org . eclipse . persistence . internal . jpa . EntityManagerSetupImpl . deploy ( EntityManagerSetupImpl . java : 369 )
at org . eclipse . persistence . internal . jpa . EntityManagerFactoryImpl . getServerSession ( EntityManagerFactoryImpl . java : 151 )
at org . eclipse . persistence . internal . jpa . EntityManagerFactoryImpl . getServerSession ( EntityManagerFactoryImpl . java : 151 )
at org . eclipse . persistence . internal . jpa . EntityManagerFactoryImpl . createEntityManagerImpl ( EntityManagerFactoryImpl . java : 207 )
at org . eclipse . persistence . internal . jpa . EntityManagerFactoryImpl . createEntityManagerImpl ( EntityManagerFactoryImpl . java : 207 )
at org . eclipse . persistence . internal . jpa . EntityManagerFactoryImpl . createEntityManager ( EntityManagerFactoryImpl . java : 195 )
at org . eclipse . persistence . internal . jpa . EntityManagerFactoryImpl . createEntityManager ( EntityManagerFactoryImpl . java : 195 )
at bdClasses . UsuariosService . getEntityManager ( at UsuariosService . getEntityManager ( UsuariosService . java : 18U suariosService . java : 18 )
at bdClasses . UsuariosService . listaUsuariosPeloNome ( at UsuariosService . listaUsuariosPeloNome ( UsuariosService . java : 28 )
at testes . NewMain . main ( NewMain . java : 9 )
at testes . NewMain . main ( NewMain . java : 9 )
Caused by : NoViableAltException ( 74 != [ 1328 : 1 : orderByItem returns [ Object node ] : ( n = stateFieldPathExpression ( a = ASC | d = DESC | ) | i = IDENT ( a = ASC | d = DESC | ) );])
Caused by : Exception [ EclipseLink -8025 ] ( Eclipse Persistence Services - 2.0.2 . v20100323 - r6872 ) : org . eclipse . persistence . exceptions . JPQLException
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . orderByItem ( JPQLParser . java : 13453 )
… 22 more
Exception Description : Syntax error parsing the query [ Usuarios . findAllOrderByName : SELECT u FROM Usuarios u order by upper ( u . nome )], line 1 , column 36 : unexpected token [ upper ].
Internal Exception : NoViableAltException ( 74 != [ 1328 : 1 : orderByItem returns [ Object node ] : ( n = stateFieldPathExpression ( a = ASC | d = DESC | ) | i = IDENT ( a = ASC | d = DESC | ) );])
at org . eclipse . persistence . exceptions . JPQLException . unexpectedToken ( JPQLException . java : 372 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . handleRecognitionException ( JPQLParser . java : 319 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . addError ( JPQLParser . java : 245 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . reportError ( JPQLParser . java : 362 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . orderByItem ( JPQLParser . java : 13605 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . orderByClause ( JPQLParser . java : 13356 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . selectStatement ( JPQLParser . java : 434 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . document ( JPQLParser . java : 276 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . parse ( JPQLParser . java : 133 )
at org . eclipse . persistence . internal . jpa . parsing . jpql . JPQLParser . buildParseTree ( JPQLParser . java : 94 )
at org . eclipse . persistence . internal . jpa . EJBQueryImpl . buildEJBQLDatabaseQuery ( EJBQueryImpl . java : 198 )
at org . eclipse . persistence . internal . jpa . JPAQuery . processJPQLQuery ( JPAQuery . java : 106 )
at org . eclipse . persistence . internal . jpa . JPAQuery . prepare ( JPAQuery . java : 90 )
at org . eclipse . persistence . queries . DatabaseQuery . checkPrepare ( DatabaseQuery . java : 464 )
at org . eclipse . persistence . queries . DatabaseQuery . checkPrepare ( DatabaseQuery . java : 430 )
at org . eclipse . persistence . internal . sessions . AbstractSession . processJPAQueries ( AbstractSession . java : 1747 )
at org . eclipse . persistence . internal . sessions . DatabaseSessionImpl . initializeDescriptors ( DatabaseSessionImpl . java : 409 )
at org . eclipse . persistence . internal . sessions . DatabaseSessionImpl . postConnectDatasource ( DatabaseSessionImpl . java : 671 )
at org . eclipse . persistence . internal . sessions . DatabaseSessionImpl . loginAndDetectDatasource ( DatabaseSessionImpl . java : 620 )
at org . eclipse . persistence . internal . jpa . EntityManagerFactoryProvider . login ( EntityManagerFactoryProvider . java : 228 )
at org . eclipse . persistence . internal . jpa . EntityManagerSetupImpl . deploy ( EntityManagerSetupImpl . java : 369 )
… 6 more
Caused by : NoViableAltException ( 74 != [ 1328 : 1 : orderByItem returns [ Object node ] : ( n = stateFieldPathExpression ( a = ASC | d = DESC | ) | i = IDENT ( a = ASC | d = DESC | ) );])
at org . eclipse . persistence . internal . jpa . parsing . jpql . antlr . JPQLParser . orderByItem ( JPQLParser . java : 13453 )
… 22 more
Java Result : 1
Pesquisando sobre o assunto encontrei este cara http://www.eclipse.org/forums/index.php/mv/tree/201707/ que parece que teve o mesmo problema que eu.
Parece que tenho que atualizar o eclipselink, vou testar e depois posto o resultado
javaimae 21 de set. de 2012
Bem atualizei o eclipselink do 2.0 para o 2.2 e parece ter resolvido meu problema, só gostaria de entender o porque no projeto Web funcionou mesmo sendo com o 2.0
Alguém sabe?