Please use the google group to ask questions - thanks.

by Eabin 09 Mar 17:17
NumberFormatException

Hi rob,

i think i have a tough one here. i'm not really sure what happens, but maybe you got an idea:

java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
java.lang.Long.parseLong(Long.java:431)
java.lang.Long.valueOf(Long.java:498)
java.lang.Long.decode(Long.java:641)
org.h2.util.MathUtils.decodeLong(MathUtils.java:160)
org.h2.value.Value.convertTo(Value.java:741)
org.h2.value.Value.getLong(Value.java:415)
org.h2.jdbc.JdbcResultSet.getLong(JdbcResultSet.java:613)
com.avaje.ebean.server.type.RsetDataReader.getLong(RsetDataReader.java:169)
com.avaje.ebean.server.type.ScalarTypeLong.read(ScalarTypeLong.java:46)
com.avaje.ebean.server.type.ScalarTypeLong.read(ScalarTypeLong.java:30)
com.avaje.ebean.server.deploy.BeanProperty.read(BeanProperty.java:565)
com.avaje.ebean.server.deploy.id.IdBinderSimple.readSet(IdBinderSimple.java:138)
com.avaje.ebean.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:225)
com.avaje.ebean.server.query.SqlTreeNodeManyRoot.load(SqlTreeNodeManyRoot.java:29)
com.avaje.ebean.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:294)
com.avaje.ebean.server.query.CQuery.readRow(CQuery.java:557)
com.avaje.ebean.server.query.CQuery.readIntoCurrentDetailCollection(CQuery.java:617)
com.avaje.ebean.server.query.CQuery.readBeanInternal(CQuery.java:602)
com.avaje.ebean.server.query.CQuery.readTheRows(CQuery.java:674)
com.avaje.ebean.server.query.CQuery.readCollection(CQuery.java:659)
com.avaje.ebean.server.query.CQueryEngine.findMany(CQueryEngine.java:166)
com.avaje.ebean.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:88)
com.avaje.ebean.server.core.OrmQueryRequest.findList(OrmQueryRequest.java:284)
com.avaje.ebean.server.core.DefaultServer.findList(DefaultServer.java:1340)
com.avaje.ebean.server.querydefn.DefaultOrmQuery.findList(DefaultOrmQuery.java:765)
tk.eabin.event.client.model.UserModel.loadItemsInternal(UserModel.java:42)


the sql statement:

select u.id c0, u.login c1, u.active c2, u.firstname c3, u.lastname c4, u.password c5, u.description c6, u.cdate c7, u.last_seen c8, u.email c9, u.home_address c10, u.jabber_id c11
        , ug.id c12, ug.name c13, ug.description c14 
from systemuser u
left outer join user_group ugz_ on ugz_.user_id = u.id 
left outer join usergroup ug on ug.id = ugz_.usergroup_id  
where u.active=1 AND (u.id=3 OR ug.id IN (1,4,5)) 
order by u.login , u.id, ug.name;

at RsetDataReader:169
i have pos==10 (so ++pos==11)
which means ebean is trying to read column c10 as a Long.
it seems it lost count somewhere?

regards,
-erwin

09 Mar 21:23
by Rob

Hmmm. I have just fixed a bug http://www.avaje.org/bugdetail-237.html

Is there any @Transient properties in use here?

09 Mar 23:25
by Eabin

yes, there is one @Transient in the systemuser class, and another java transient too.
also, the method corresponding to the @Transient field is marked as @Transient.

will test with HEAD and report back.

10 Mar 00:02
by Eabin

ugh, there is something wrong here. with rev. 770 i can't login to my application anymore. the first persist throws:

javax.persistence.PersistenceException: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement UPDATE SYSTEMUSER SET WHERE[*] ID=? ; expected identifier; SQL statement:
update systemuser set where id=? [42001-79]
at org.h2.message.Message.getSQLException(Message.java:103)
at org.h2.message.Message.getSQLException(Message.java:114)
at org.h2.message.Message.getSyntaxError(Message.java:139)
at org.h2.command.Parser.readColumnIdentifier(Parser.java:2480)
at org.h2.command.Parser.readTableColumn(Parser.java:604)
at org.h2.command.Parser.parseUpdate(Parser.java:658)
at org.h2.command.Parser.parsePrepared(Parser.java:412)
at org.h2.command.Parser.parse(Parser.java:288)
at org.h2.command.Parser.parse(Parser.java:260)
at org.h2.command.Parser.prepareCommand(Parser.java:232)
at org.h2.engine.Session.prepareLocal(Session.java:285)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:211)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:127)
at java.lang.Thread.run(Thread.java:619)

at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.execute(DmlBeanPersister.java:108)
at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.update(DmlBeanPersister.java:84)
at com.avaje.ebeaninternal.server.persist.DefaultPersistExecute.executeUpdateBean(DefaultPersistExecute.java:121)
at com.avaje.ebeaninternal.server.core.PersistRequestBean.executeNow(PersistRequestBean.java:390)
at com.avaje.ebeaninternal.server.core.PersistRequestBean.executeOrQueue(PersistRequestBean.java:416)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.update(DefaultPersister.java:383)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveEnhanced(DefaultPersister.java:303)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveRecurse(DefaultPersister.java:275)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.save(DefaultPersister.java:259)
at com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:1448)
at com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:1438)
at com.avaje.ebean.Ebean.save(Ebean.java:526)
at tk.eabin.util.db.EbeanUtil.save(EbeanUtil.java:18)
at tk.eabin.event.server.EventingerAuthenticator.authenticate(EventingerAuthenticator.java:24)
at tk.eabin.event.server.EventingerAuthenticator.authenticate(EventingerAuthenticator.java:16)
at tk.eabin.util.net.remote.server.Server.onAuth(Server.java:180)
at tk.eabin.util.net.remote.server.Server.access$300(Server.java:32)
at tk.eabin.util.net.remote.server.Server$1.work(Server.java:170)
at tk.eabin.util.net.SharedSocketMaster$WorkerCaller.run(SharedSocketMaster.java:232)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement UPDATE SYSTEMUSER SET WHERE[*] ID=? ; expected identifier; SQL statement:
update systemuser set where id=? [42001-79]
at org.h2.message.Message.getSQLException(Message.java:103)
at org.h2.message.Message.getSQLException(Message.java:114)
at org.h2.message.Message.getSyntaxError(Message.java:139)
at org.h2.command.Parser.readColumnIdentifier(Parser.java:2480)
at org.h2.command.Parser.readTableColumn(Parser.java:604)
at org.h2.command.Parser.parseUpdate(Parser.java:658)
at org.h2.command.Parser.parsePrepared(Parser.java:412)
at org.h2.command.Parser.parse(Parser.java:288)
at org.h2.command.Parser.parse(Parser.java:260)
at org.h2.command.Parser.prepareCommand(Parser.java:232)
at org.h2.engine.Session.prepareLocal(Session.java:285)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:211)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:127)
at java.lang.Thread.run(Thread.java:619)

at org.h2.engine.SessionRemote.done(SessionRemote.java:407)
at org.h2.command.CommandRemote.prepare(CommandRemote.java:68)
at org.h2.command.CommandRemote.(CommandRemote.java:47)
at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:340)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1063)
at org.h2.jdbc.JdbcPreparedStatement.(JdbcPreparedStatement.java:72)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:240)
at com.avaje.ebeaninternal.server.lib.sql.PooledConnection.prepareStatement(PooledConnection.java:380)
at com.avaje.ebeaninternal.server.lib.sql.PooledConnection.prepareStatement(PooledConnection.java:350)
at com.avaje.ebeaninternal.server.persist.dml.DmlHandler.getPstmt(DmlHandler.java:285)
at com.avaje.ebeaninternal.server.persist.dml.UpdateHandler.bind(UpdateHandler.java:67)
at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.execute(DmlBeanPersister.java:97)
... 21 more

10 Mar 00:05
by Eabin

the value that should be updated is a custom ScalarType if this is any help. works fine on 2.4.0 though.

10 Mar 09:56
by Rob

The problem here is there is nothing in the set clause of the update statement.

Can you create a test case that reproduces the problem?

10 Mar 12:11
by Eabin

it seems that the custom ScalarType is not recognized anymore. did you change anything in the way you search for custom ScalarTypes?

10 Mar 12:23
by Eabin

ok, looks like a compile problem on my part....my custom type is not assignable to ScalarType.

10 Mar 12:31
by Eabin

ok, so what's the difference between ebean and ebeaninternal?

from EbeanServerFactory:createServerFactory:

//		String d___ =  com.avaje.ebean.server.core.DefaultServerFactory.class.getName();
		String dflt = "com.avaje.ebeaninternal.server.core.DefaultServerFactory";
10 Mar 12:35
by Eabin

change the custom type to implement ebeaninternal ScalarType, and it seems to work.

however, the bad news is that the NumberFormatException is still present.

10 Mar 14:58
by Eabin

ouch. turns out i didn't implement loadIgnore() in my ScalarType. will think of a suitable punishment for myself now.

closed :)

11 Mar 07:47
by Rob

Cool.

FYI: the com.avaje.ebeaninternal ... is there because I wanted to explicitly separate the internal implementation from the ebean api.

Previously we had used maven submodules and I really wanted to simplify the build/deploy.

12 Mar 16:35
by Eabin

ok, so if i have to subclass ebeaninternal...ScalarType, this is a bug, right?

13 Mar 22:41
by Rob

Well, I don't know about bug (seems a bit strong).

The preferred way would be to use

com.avaje.ebean.config.ScalarTypeConverter

or for compound types:

com.avaje.ebean.config.CompoundType

These where added in v2.3.0 for better support of immutable value objects.

http://groups.google.com/group/ebean/browse_thread/thread/39cfec09bd577d33/95261208c2372546?lnk=gst&q=value+objects#95261208c2372546


I could maybe look to move the ScalarType interfaces into the public side or spi area but I think people should probably be trying those other interfaces first as they are much simpler to implement.

Cheers, Rob.

Create a New Topic

Title:
Body:
 
Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse