Skip to Content
avatar image
Former Member

persistence unit is inconsistent

Hi all,

I have a problem with my primary key generation, my class looks as follows:

-


@Entity

@Table(name="MYAPP_M_CUST")

public class Customer implements Serializable {

@Id

@Column(name="CUST_ID")

@GeneratedValue (strategy=GenerationType.TABLE, generator="myGen")

@TableGenerator(name = "myGen", table = "MY_GENERATOR_TABLE")

private int custId;

...

}

-


when i try to persist a new "Customer" via the entity manager i get a

-


Caused by: com.sap.engine.lib.injection.InjectionException: Injection on field em of instance com.mycompany.myapp.CustServiceBean@1daef87 failed. Could not get a value to be injected from the factory.

at com.sap.engine.lib.injection.FieldInjector.inject(FieldInjector.java:115)

at com.sap.engine.lib.injection.InjectionMatrix.inject(InjectionMatrix.java:45)

at com.sap.engine.services.ejb3.runtime.impl.Interceptors_DependencyInjection.invoke(Interceptors_DependencyInjection.java:22)

... 101 more

Caused by: java.lang.RuntimeException: The persistence unit is inconsistent with the database schema:

Error on attribute >>com.mycompany.myapp.Customer.custId<<: The generator table >>MY_GENERATOR_TABLE<< does not exist.

-


which makes me wonder because i created the "MY_GENERATOR_TABLE" table with the following definition:

-


CREATE TABLE "SAPNDWDB"."MY_GENERATOR_TABLE"

(

"GEN_KEY" Varchar (256) UNICODE NOT NULL,

"GEN_VALUE" Integer,

PRIMARY KEY("GEN_KEY")

)

-


and I can see it via the SQL Studio.

Without the key generation the persist works fine and writes data to the table.

Any ideas?

Regards,

Christian

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 19, 2008 at 10:06 PM

    Hi Christian,

    Are you running your app on the System DataSource? If so, you have to create all tables using the Java Dictionary. You find more information [here|http://help.sap.com/saphelp_nwce10/helpdata/en/45/c8baeb5f0c2e97e10000000a155369/frameset.htm].

    HTH!

    \-- Vladimir

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 21, 2008 at 09:35 AM

    Hi Vladimir,

    using the dictionary did the trick, thanks!

    Regards,

    Christian

    Add comment
    10|10000 characters needed characters exceeded