Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

org.openspaces.core.ObjectConversionException

  • I??m trying to save an object in a Postresql DB using Hibernate and SBA. I??m using org.openspaces.core.GigaSpace.write() but....

Field name: id is declared as primary key and can't be null before the writing operation.; nested exception is com.gigaspaces.converter.ConversionException: Field name: id is declared as primary key and can't be null before the writing operation.

  • When I set an id value, the result is:

GRAVE: Exception executing batch: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=1926]{quote}

asked 2008-04-09 16:12:40 -0600

nullcipher2 gravatar image

updated 2013-08-08 09:52:00 -0600

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

Hi Jorge

Can you please attach the following to your post:
- Code of your POJO
- Hibernate mapping file
- OpenSpaces pu.xml (if you have more than one then please send all of them)
- Any other information you think is relevant

Thanks,
Uri

answered 2008-04-10 02:47:27 -0600

uri gravatar image
edit flag offensive delete link more

Comments

The main idea is: How can I write an object to the space without setting the id(SpaceId), I need the id to be auto-generated:

public class POJO extends VO {

private static final long serialVersionUID = -4381715866971353658L;

private String script;
private Long id;

@SpaceProperty(index=IndexType.NONE)
public String getScript() {
    return script;
}

@SpaceId
@SpaceProperty(index=IndexType.BASIC)
public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id=id;
}

public void setScript(String script) {
    this.script=script;
}

}

  • This is called from:

POJO cons = new POJO();

cons.setScript("test script");

nullcipher2 gravatar imagenullcipher2 ( 2008-04-10 11:55:40 -0600 )edit
  • I think this is my problem:

http://www.openspaces.org/forum/threa...

  • And this is the solution:

When running in ExternalDataSource mode (write behind/through) the space must have some sort of application UID embedded into the object to correlate it with the database table row data.

HOW CAN I DO THAT?

Thanks

nullcipher2 gravatar imagenullcipher2 ( 2008-04-10 14:32:37 -0600 )edit

That means you have to set the SpaceId field manually with a unique value, and make sure it's configured at follows: @SpaceId(autogenerate=false)

uri gravatar imageuri ( 2008-04-12 13:45:04 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2008-04-09 16:12:40 -0600

Seen: 79 times

Last updated: Apr 10 '08