These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: java.sql.BatchUpdateException: Batch entry 0 insert into bt.
PostPosted: Sun Oct 04, 2009 3:33 pm 
Newbie

Joined: Sun Oct 04, 2009 3:16 pm
Posts: 2
I saw a similar topic -- viewtopic.php?p=2267123

I have tried "lower case" of all database fields and it does not work.

This is the exception I get.
java.sql.BatchUpdateException: Batch entry 0 insert into bt.users (username, password, admin_roles_id, id) values (raag5, password, 3, 110) was aborted. Call getNextException to see the cause.
org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2537)
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1328)
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:351)
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2674)
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
...

Here is the hbm.xml file
<hibernate-mapping package="com.bizzytime.model" default-lazy="false">
<class name="User" table="bt.users">
<id name="id" type="java.lang.Long" column="id" unsaved-value="0">
<generator class="sequence">
<param name="sequence">bt.user_id_seq</param>
</generator>
</id>
<property name="username" column="username" type="string"/>
<property name="password" column="password" type="string"/>

<many-to-one name="role" class="AdminRole" fetch="select">
<column name="admin_roles_id" precision="4" scale="0" />
</many-to-one>
</class>
</hibernate-mapping>

Here is my table
CREATE TABLE bt.users
(
id bigint NOT NULL,
username character varying(32) NOT NULL,
"password" character varying(32) NOT NULL,
admin_roles_id bigint NOT NULL DEFAULT 1,
CONSTRAINT user_pk PRIMARY KEY (id),
CONSTRAINT user_admin_roles_fk FOREIGN KEY (admin_roles_id)
REFERENCES bt.admin_roles (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE bt.users OWNER TO postgres;

CREATE INDEX user_admin_roles_fk
ON bt.users
USING btree
(admin_roles_id);

The query can be executed successfully in pgAdmin III with single quotes around the text fields
insert into bt.users (username, password, admin_roles_id, id) values ('raag5', 'password', 3, 110)

I am running "postgresql-8.4.1-1-windows.exe" on Windows XP

Could someone help me?

Thanks
-- Raag


Top
 Profile  
 
 Post subject: Re: java.sql.BatchUpdateException: Batch entry 0 insert into bt.
PostPosted: Sun Oct 04, 2009 3:47 pm 
Newbie

Joined: Sun Oct 04, 2009 3:16 pm
Posts: 2
I solved the problem. Seems I missed a few grants

Originally this was the default script - ALTER TABLE bt.users OWNER TO postgres;

There were other roles and groups to which I needed to grant access.

-- Raag


Top
 Profile  
 
 Post subject: Re: java.sql.BatchUpdateException: Batch entry 0 insert into bt.
PostPosted: Sat Apr 10, 2010 4:07 pm 
Newbie

Joined: Sat Apr 10, 2010 4:02 pm
Posts: 2
Hi Raag

Im having the same problem. I only have user postgres and I haven't run ALTER TABLE <tablename> OWNER TO postgres

Do i have to run that line? What do you mean by "There were other roles and groups to which I needed to grant access". Do i have to grant access to other roles and groups? In my Postgre I only have user postgres. I haven't created groups or roles.

Agustin


Top
 Profile  
 
 Post subject: Re: java.sql.BatchUpdateException: Batch entry 0 insert into bt.
PostPosted: Sat Apr 10, 2010 6:24 pm 
Newbie

Joined: Sat Apr 10, 2010 4:02 pm
Posts: 2
Hi

The error I get is:

java.sql.BatchUpdateException: Batch entry 0 insert into qm_project (creationdate, description, lastmodifieddate, name, shortname, id) values ('2010-04-10 17:16:16.031000 -05:00:00', 'cc', '2010-04-10 17:16:16.031000 -05:00:00', 'ee', 'qq', '16') was aborted. Call getNextException to see the cause.

The SQL statement you see there, i copied and pasted in the pgAdminIII and it fails because of that weird field "id". My qm_project table doesnt have a column with that name!!! When I execute that SQL statement in the pgAdmin without that weird "id", the insert is succesful! So how do I tell hibernate to eliminate that extra field in the SQL statement he is building?! instead of "id", my qm_project table has a column called "project_id" which is the PK and is just an integer that increments with a sequence I already defined, and in the POJO I already put the necessary annotations for that sequence. Please help I don't know how to solve this.

Agustin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.