我收到一个奇怪的错误,我无法在eclipse中重现但出现在服务器上。
表示:
Caused by: java.sql.BatchUpdateException: Batch entry 0
update public.user set
is_at='[B@136ef65',
user_name='elk',
password='33e79218965eb72c92a549dd5a330113',
location_precision=NULL,
location_simulated=NULL,
active=NULL,
last_seen_at='2013-02-20 08:13:45.992000 +01:00:00',
app_uuid=NULL,
avatar_url='http://server.org/img/avatars/10.png',
email='mail@mail.com',
score=NULL,
phrase='hibernate fail',
state=NULL,
reputation=NULL,
reputation_desc=NULL,
privacy_settings='visibleForAll',
gender='male',
email_verified='1',
geom='SRID=4326;POINT(2.209740161895752 41.400447845458984)'
where user_id='[B@19ee400'
was aborted. Call getNextException to see the cause.
跟随
java.lang.IllegalArgumentException: id to load is required for loading
失败是因为(hibernate?)无法将属性is_at和user_id转换为字符串。它似乎尝试使用对象上的二进制表示形式对查询进行参数化。
相关的hbm.xml片段:
<id name="userId" type="java.lang.Long">
<column name="user_id" />
<generator class="sequence">
<param name="sequence">user_user_id_seq</param>
</generator>
</id>
<many-to-one name="checkin" class="org.server.entity.Checkin" fetch="select">
<column name="is_at" />
</many-to-one>
我看不出什么奇怪的,也许更多的眼睛看到更多?奇怪的是,我的IDE正在运行。有人见过类似的错误吗?
休眠:3.6.2
版本tomcat 6.0.33
java openjdk 1.6.0.18
postgresql:8.3.9
更新:
此代码的Java代码:
// queryHistory is to be persisted
// user is not null
queryHistory.setUser(user);
queryHistory.setApiKey(apiKey);
// create point
Coordinate coordinate = new Coordinate(queryHeader.getLocLon(),queryHeader.getLocLat());
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(),4326);
Point point = geometryFactory.createPoint(coordinate);
queryHistory.setGeom(point);
if(user!=null) {
user.setGeom(point);
user.setLastSeenAt(new Timestamp(new Date().getTime()));
hSession.update(user);
}
hSession.persist(queryHistory);
t.commit();
提前致谢