Fala galera!!!
To executando essa consulta no BD:
[code] public List<Cliente> getAllClientes(int firstResult, int maxResults) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistenceUnit");
manager = emf.createEntityManager();
Query query = manager.createQuery("select nome from CLIENTES");
if(maxResults>0){
query.setFirstResult(firstResult);
}
return query.getResultList();
}[/code]
E tá dando o seguinte erro:
[TopLink Info]: 2007.12.14 02:09:13.171--ServerSession(29194312)--TopLink, version: Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))
[TopLink Info]: 2007.12.14 02:09:16.093--ServerSession(29194312)--file:/H:/Projetos/pocEJB3/bin/-persistenceUnit login successful
[TopLink Warning]: 2007.12.14 02:09:16.828--ServerSession(29194312)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Table/View 'CLIENTES' already exists in Schema 'CIANET'.
Error Code: 30000
Call: CREATE TABLE CLIENTES (ID INTEGER NOT NULL, NOME VARCHAR(255), SOBRENOME VARCHAR(255), IDADE INTEGER, PRIMARY KEY (ID))
Query: DataModifyQuery()
[TopLink Warning]: 2007.12.14 02:09:18.015--ServerSession(29194312)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Table/View 'SEQUENCE' already exists in Schema 'CIANET'.
Error Code: 30000
Call: CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL, PRIMARY KEY (SEQ_NAME))
Query: DataModifyQuery()
1
Exception in thread "main" java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:194)
at ClienteDAOBean.getAllClientes(ClienteDAOBean.java:24)
at ClienteDAOBean.getAllClientes(ClienteDAOBean.java:17)
at Main.main(Main.java:17)
Caused by: Exception [TOPLINK-8028] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.EJBQLException
Exception Description: Syntax error parsing the query [select nome from CLIENTES], line 1, column 26: unexpected end of query.
Internal Exception: line 1:26: unexpected token: null
at oracle.toplink.essentials.exceptions.EJBQLException.unexpectedEOF(EJBQLException.java:404)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.handleANTLRException(EJBQLParser.java:330)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.addError(EJBQLParser.java:262)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.reportError(EJBQLParser.java:362)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.rangeVariableDeclaration(EJBQLParser.java:1742)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.identificationVariableDeclaration(EJBQLParser.java:1621)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.fromClause(EJBQLParser.java:454)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.selectStatement(EJBQLParser.java:179)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.document(EJBQLParser.java:135)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.parse(EJBQLParser.java:150)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.buildParseTree(EJBQLParser.java:111)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:200)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:174)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:138)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:99)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:84)
at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.<init>(EJBQueryImpl.java:71)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:189)
... 3 more
Caused by: line 1:26: unexpected token: null
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.rangeVariableDeclaration(EJBQLParser.java:1727)
... 16 more
Já tentei alterar essa query de todas as formas… mas não dei jeito…
Alguém tem alguma idéia do que seja?
Abraço!!!