on 01-17-2008 1:12 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vladimir,
using the dictionary did the trick, thanks!
Regards,
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.