Skip to Content
0
Former Member
Jan 17, 2008 at 01:12 PM

persistence unit is inconsistent

44 Views

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