Try following
select a from ModuleGroup as a where a.company is NULL or a.company.id=1201149432740*L*
That is suffixing L to the numeric constant
glassfish_at_javadesktop.org wrote:
> Hello!
>
> I'm currently trying to migrate an existing ejb-project from JBoss to Glassfish. Now I'm having problems with my EJB QL statements.
>
> Most of my entities have an id-field that has the type "long":
>
> @Id
> public long getId() {
> return id;
> }
>
> I don't use auto-generated values because I am using a class that generates unique-ids for me. All my enities that are already existing in the database have these ids.
>
> Now I'm tryingto execute a quite simple query:
>
> select a from ModuleGroup as a where a.company is NULL or a.company.id=1201149432740
>
> The id that is mentioned is an id from an existing company. This query works fine in JBoss but when I execute it within Glassfish I get the following error:
>
> Caused by: Exception [TOPLINK-8002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/17/2008))): oracle.toplink.essentials.exceptions.EJBQLException
> Exception Description: General Problem parsing the query [select a from ModuleGroup as a where a.company is NULL or a.company.id=1201149432740 order by a.id]. The parser returned the following [For input string: "1201149432740"].
> Internal Exception: java.lang.NumberFormatException: For input string: "1201149432740"
> at oracle.toplink.essentials.exceptions.EJBQLException.generalParsingException(EJBQLException.java:140)
> at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.addError(EJBQLParser.java:280)
> at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.parse(EJBQLParser.java:168)
> at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.buildParseTree(EJBQLParser.java:127)
> at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:215)
> at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:189)
> at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:153)
> at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:114)
> at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:99)
> at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.<init>(EJBQueryImpl.java:86)
> at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:204)
> ... 77 more
> Caused by: java.lang.NumberFormatException: For input string: "1201149432740"
> at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
> at java.lang.Integer.parseInt(Integer.java:459)
> at java.lang.Integer.valueOf(Integer.java:553)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.literalNumeric(EJBQLParser.java:3080)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.arithmeticPrimary(EJBQLParser.java:3578)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.arithmeticFactor(EJBQLParser.java:3513)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.arithmeticTerm(EJBQLParser.java:3407)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.simpleArithmeticExpression(EJBQLParser.java:1021)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.arithmeticExpression(EJBQLParser.java:2304)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.comparisonExpressionRightOperand(EJBQLParser.java:3304)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.comparisonExpression(EJBQLParser.java:2441)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.simpleConditionalExpressionRemainder(EJBQLParser.java:2346)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.simpleConditionalExpression(EJBQLParser.java:2283)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.conditionalPrimary(EJBQLParser.java:2218)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.conditionalFactor(EJBQLParser.java:2155)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.conditionalTerm(EJBQLParser.java:2030)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.conditionalExpression(EJBQLParser.java:1996)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.whereClause(EJBQLParser.java:507)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.selectStatement(EJBQLParser.java:184)
> at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.document(EJBQLParser.java:135)
> at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.parse(EJBQLParser.java:166)
> ... 85 more
>
> Toplink always tries to interprete the long-values as integer which fails. Can anybody help me? I'm using Glassfish 2ur2 with PostgreSQL 8.3 as database.
>
> Achim
> [Message sent by forum member 'hilwi' (hilwi)]
>
> http://forums.java.net/jive/thread.jspa?messageID=288775
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>