[Incoming Payments for WTax] Primary Key not exist in DB
While performing the TDS upgrade, I am getting an error message as "[Incoming Payments for WTax] Primary Key not exist in DB".
I have checked that the sheet conforms to the instructions provided in the Upgrade guide but am not able to resolve this.
Any ideas?
Regards,
Gyanesh
Hi,
It seems to be some field in the TDS upload Excel sheet which has primary key field not having the correct value.
Double check the same where Primary Key if linked with some value in other sheet, enter the same.
Kind Regards,
Jitin
SAP Business One Forum Team
Similar Messages
-
Posting Keys for Account Determination do not exist
This doubt in STO scenario:
STO - between 2 plants - different company codes under same client
Created STO from Receiving Plant in ME21N with document type NB
Based on that STO, Created Delivery in VL10B from supplying Plant
Tried PGI in VL02N from supplying Plant.
Received the Error Message as below:
Posting keys for account determination for transaction BUV do not exist
Message no. F5598
Diagnosis
The posting keys necessary for account determination for transaction BUV have not been set.
System Response
Because the posting key is missing, the system cannot generate any automatic postings.
Procedure
Maintain the posting keys necessary for transaction BUV.
kindly give the solution and advance thanks.
VaideeHi Vadee,
Account Determination for BUV has not been setup for PGI.
So , go to transaction OBYC and assign the account by double clicking BUV and give u r chart of accounts and check whether the account has been maintained. If not maintain.
If account has been maintained , select your account/valuation class and select posting keys push button and maintain the posting keys.
Regards,
Nani -
Posting keys for account determination for transaction EXC do not exist
hi
i am doing Sales order for 1 month,no error i have got
but now i am getting error
Posting keys for account determination for transaction EXD do not exist
HELPThere will not be any such postings called FI side / SD Side.
Positng always done in Financial perspective only into Certain G/L accounts depends on configuration we did.
As we know,
To post Invoice Conditions in G/L accounts , we configure Account Determination . These tables will be communicated through Account keys maintained in Pricing procedure & in Account determination tables.
To account the stock in Inventory, will configure the same in OBYC - FI/MM Account Determination.- this will be triggered through Movement type - Transaction key / General modifier / Valuation calss / Valution group code n other factors.
In your issue,
Which Postings you are referring to?
In SO creation, Controlling documents will be created ( Ref: COPA - Controlling & Profitablity Analysis Customization)
After PGI in Delivery: Inventory will accounted through OBYC settings
After releasing invoice to Accounting, G/L accounts posted through VKOA settings.
Hope ,now you provide exact information related to your query -
Posting keys for account determination for transaction EXD do not exist
hi
i am doing Sales order for 1 month,no error i have got
but now i am getting error
Posting keys for account determination for transaction EXD do not exist
HELPHello,
I have following suggestion to overcome this issue.
1. In the t-code "FTXP", check for assignment of the G/L account for the posting key.
2. Check out the SAP Note:200348.
3. In t-code "OBCN",for the account key EXD, make sure that the value of posting indicator is 2.
4. In t-code OBYZ, for the tax calculation procedures, change the key to EXD. The account keys in tax pricing procedures and SD pricing procedures Should be same.
Regards,
Sarthak -
Posting keys for account determination for transaction ERS do not exist
Dear All,
When I try to create an accounting document for a billing document, the below error happened:
Posting keys for account determination for transaction ERS do not exist.
Could any one of you meet the issue before and give me some advice? Thanks a lot.
RayDear,
In your pricing procedure check whether any sales deductions / discounts condition type is maintained and against that maintain ERS account key.
and Go to VKOA and maintain gl account against your Kofi and KOFK for account key ERS.
try and let us know
regards,
SUdhir -
Is this good approach for generating Primary Keys ?
Hi,
All our EJBs are state less Session Beans.
We have created a state less Session(name SequenceEJB) for getting Primary Key.
Thre is a method,
int getSequenceNumber(String tableName,String fieldName) in SequenceEJB. And the following query is used in the above said method.
SELECT MAX("+fieldName+") ID FROM "+tableName
Each EJB will lookup SequenceEJB, and call the above said method for getting sequence number.
Is this approach sclable ?
Can we proceed by this approach ?
Thanks in advance
SrinivasAs long as you are in EJB, synchronization won't help you because it is not permitted by the EJB spec.
If you can go with JDBC 3.0 / Java 1.4, the statement interface supportes generated keys. See http://java.sun.com/j2se/1.4/docs/api/java/sql/Statement.html.
If you cannot go with JDBC 3.0 / Java 1.4, you can implement the key-generation db-specific (e.g. using oracle sequences for oracle tables, and whatever exists for DB2, SQL Server etc.) That of course requires special support for all databases, but at least you can run your app with different databases.
Or you can try to do it the following way, using a separate table for the keys.
ResultSet rs = statement.executeQuery("select id from mySequences");
oldId = rs.getInt(1);
newId = oldId + 1
int updatedRows = statement.executeQuery("update mySequences set id = newId where id = oldId");
if(updatedRows == 1) {
// succesful
} else {
// not sucessful, somebody else has already retrieve this id; do something like Thread.sleep() and retry
}This way, the database does the actual synchronization between the processes (each process sees the same data in the tables), and you implement the retry logic. -
Checking for duplicate primary keys on row inserts
Checking for duplicate primary keys on row inserts
I have a situation where I will be making bulk table inserts knowing that the primary key value will in some cases already exist. In this is the case I simply want to ignore the duplicate inserts.
Should I be performing a sub-query on the table and using a statement like:
where not exist in
Or is there a cleaner way of discarding or checking for duplicates on insert.
My concerns were mainly one of performance, as my routine will be inserting a few thousand rows in its operation.The MERGE commnad is a good option when a large percentage of the data will exist in the target because it is much more efficient to attempt to update then insert when the update affects zero rows than capture an error and convert it to an update.
However, since in this case it would appear that only a few rows will alreadys exist and we want to ignore the duplicates when they exist then
begin
insert
exception
when dup_value_in_index then null;
end
would be the way to code this one. The bulk insert version has in 9.2 the ability to store the errors so that they can all be handled at once which means the rest of the array insert can work.
HTH -- Mark D Powell -- -
NULL in primary keys NOT logged to exceptions table
Problem: Inconsistent behavior when enabling constraints using the "EXCEPTIONS INTO" clause. RDBMS Version: 9.2.0.8.0 and 10.2.0.3.0
- NULL values in primary keys are NOT logged to exceptions table
- NOT NULL column constraints ARE logged to exceptions table
-- Demonstration
-- NULL values in primary keys NOT logged to exceptions table
TRUNCATE TABLE exceptions;
DROP TABLE t;
CREATE TABLE t ( x NUMBER );
INSERT INTO t VALUES ( NULL );
ALTER TABLE t
ADD ( CONSTRAINT tpk PRIMARY KEY (x) EXCEPTIONS INTO exceptions );
SELECT * FROM exceptions; -- returns no rows
-- NOT NULL column constraints logged to exceptions table
TRUNCATE TABLE exceptions;
DROP TABLE t;
CREATE TABLE t ( x NUMBER );
INSERT INTO t VALUES ( NULL );
ALTER TABLE t MODIFY ( X NOT NULL EXCEPTIONS INTO EXCEPTIONS );
SELECT * FROM exceptions; -- returns one row
I would have expected all constraint violations to be logged to exceptions. I was not able to find any documentation describing the behavior I describe above.
Can anyone tell me if this is the intended behavior and if so, where it is documented?
I would also appreciate it if others would confirm this behavior on their systems and say if it is what they expect.
Thanks.
- Doug
P.S. Apologies for the repost from an old thread, which someone else found objectionable.I should have posted the output. Here it is.
SQL>TRUNCATE TABLE exceptions;
Table truncated.
SQL>DROP TABLE t;
Table dropped.
SQL>CREATE TABLE t ( x NUMBER );
Table created.
SQL>INSERT INTO t VALUES ( NULL );
1 row created.
SQL>ALTER TABLE t ADD ( CONSTRAINT tpk PRIMARY KEY (x) EXCEPTIONS INTO exceptions );
ALTER TABLE t ADD ( CONSTRAINT tpk PRIMARY KEY (x) EXCEPTIONS INTO exceptions )
ERROR at line 1:
ORA-01449: column contains NULL values; cannot alter to NOT NULL
SQL>SELECT * FROM exceptions;
no rows selected
SQL>
SQL>TRUNCATE TABLE exceptions;
Table truncated.
SQL>DROP TABLE t;
Table dropped.
SQL>CREATE TABLE t ( x NUMBER );
Table created.
SQL>INSERT INTO t VALUES ( NULL );
1 row created.
SQL>ALTER TABLE t MODIFY ( X NOT NULL EXCEPTIONS INTO EXCEPTIONS );
ALTER TABLE t MODIFY ( X NOT NULL EXCEPTIONS INTO EXCEPTIONS )
ERROR at line 1:
ORA-02296: cannot enable (MYSCHEMA.) - null values found
SQL>SELECT * FROM exceptions;
ROW_ID OWNER TABLE_NAME CONSTRAINT
AAAkk5AAMAAAEByAAA MYSCHEMA T T
1 row selected.
As you can see, I get the expected error message. But I only end up with a record in the exceptions table for the NOT NULL column constraint, not for the null primary key value. -
How do I obtain the next number for a Primary Key using an ADF View Object?
I have two separate View Objects (A & B) for the same Entity Object. View Object A does a SELECT on all of the fields in the table. This View Object is where I execute my adds and updates. View Object B is only used to retrieve the next number for the primary key. This is done so that when I add a row to the database, I always get the max number of the primary key and add one to it. I accomplished this by setting the SQL mode to Expert and using the SQL: "SELECT MAX(NBR) AS MAX_NUMBER FROM TABLE_1". This may be overkill having a seperate View Object for this, but so far this is the only way I have found to obtain the next number. However, I have discovered that this way does not always work.
The problem I'm running into is when I try to add multiple records to View Object A without committing the transaction between each add. Because View Object B is disconnected from View Object A, the MAX_NUMBER of View Object B comes back with the same number for each add I do on View Object A. So I know I must retrieve the MAX_NUMBER from View Object A.
I've tried using the following code in my Table1ViewImpl class:
this.setQuery("SELECT MAX(Table1.NBR) AS MAX_NUMBER FROM TABLE_1 Table1");
this.executeQuery();
The view object now has what I want, but I have yet to figure a way to extract the MAX_NUMBER out of the View Object. I've also looked into using the method addDynamicAttribute() but I can't figure out any way to set the attribute with the MAX_NUMBER.
I can't be the only one trying to retrieve the next number from a database table using ADF. Can anyone help me with this? FYI - I'm using JDev 10.1.3 EA.You missing the point.
On a multi-user db knowing the next highest number doesn't guarantee the number will be available when it comes time to commit the record. You can prove this to yourself by opening two instances of your app and do whatever you do to add a new record to your VO. Both will assume the same number, and when you commit an error will be generated
You must use sequences to avoid the possibility of duplicate keys. If you are trying to avoid gaps in your numbering then you need to convince yourself why this is necessary. -
How to specify tablespace for a primary key inde in create table statement
How to specify the tablespace for a primary key index in a create table statement?
Does the following statement is right?
CREATE TABLE 'GPS'||TO_CHAR(SYSDATE+1,'YYYYMMDD')
("ID" NUMBER(10,0) NOT NULL ENABLE,
"IP_ADDRESS" VARCHAR2(32 BYTE),
"EQUIPMENT_ID" VARCHAR2(32 BYTE),
"PACKET_DT" DATE,
"PACKET" VARCHAR2(255 BYTE),
"PACKET_FORMAT" VARCHAR2(32 BYTE),
"SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") TABLESPACE "INDEX_DATA"
TABLESPACE "SBM_DATA"; Thank you
Edited by: qkc on 09-Nov-2009 13:42As orafad indicated, you'll have to use the USING INDEX clause from the documentation, i.e.
SQL> ed
Wrote file afiedt.buf
1 CREATE TABLE GPS
2 ("ID" NUMBER(10,0) NOT NULL ENABLE,
3 "IP_ADDRESS" VARCHAR2(32 BYTE),
4 "EQUIPMENT_ID" VARCHAR2(32 BYTE),
5 "PACKET_DT" DATE,
6 "PACKET" VARCHAR2(255 BYTE),
7 "PACKET_FORMAT" VARCHAR2(32 BYTE),
8 "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
9 CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") USING INDEX TABLESP
ACE "USERS"
10 )
11* TABLESPACE "USERS"
SQL> /
Table created.Justin -
How to change the source type for a primary key on a form?
Hi,
At the time of creating a form, I had set the source type for the primary key to an existing sequence.
Now I want to change the source to a trigger.
Can anyone suggest how to do it?
Thanks in advance,
AnnieAnnie:
Define the trigger and then delete the page process named 'Get PK'
Varad -
Creating a script for a PRIMARY KEY USING INDEX SORT doesn't work
Probably a bug.
h1. Environment
Application: Oracle SQL Developer Data Modeler
Version: 3.0.0.655
h1. Test Case:
1. Create a new table TRANSACTIONS with some columns.
2. Mark one of numeric columns as the primary key - PK_TRANSACTIONS.
3. Go to Physical Models and create new Oracle Database 11g.
4. Go to Physical Models -> Oracle Database 11g -> Tables -> TRANSACTIONS -> Primary Keys -> PK_TRANSACTIONS -> Properties:
a) on General tab set Using Index to BY INDEX NAME
b) on Using Index tab choose a tablespace
c) on Using Index tab set Index Sort to SORTED.
5. Export the schema to DDL script. For the primary key you will get something like this:
ALTER TABLE TRANSACTION
ADD CONSTRAINT PK_TRANSACTION PRIMARY KEY ( TRAN_ID ) DEFERRABLE
USING INDEX
PCTFREE 10
MAXTRANS 255
TABLESPACE TBSPC_INDX
LOGGING
STORAGE (
INITIAL 65536
NEXT 1048576
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 2147483645
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
) SORTED
h1. Reason of failure
The script will fail because SORTED is not allowed here. It should be SORT.
Additionally, the default behaviour for Data Modeler is to set Index Sort to NO but default setting for Oracle database 11g is SORT. Shouldn't Data Modeler use SORT as the default value?
Edited by: user7420841 on 2011-05-07 03:15Hi,
Thanks for reporting this problem. As you say, it should be SORT rather than SORTED. I have logged a bug on this.
I also agree that, for consistency with the database default, it would be better to have SORT as the default in Data Modeler.
David -
EJB Primary Key not found in lock manager - Container BUG?
I have an EJB entity bean whose primary key class implementation is pretty simple, consisting of two strings. For the MOST part, it seems to work properly, but every so often I see the following message in my application server log.
####<Sep 17, 2008 10:03:27 AM EDT> <Warning> <JTA> <armantac22> <AdminServer> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1221660207187> <BEA-110401> <Ignoring error in afterCompletion. Object=weblogic.ejb.container.internal.TxManager$TxListener@1906466, Exception=javax.ejb.EJBException: [EJB:010108]The EJB Lock Manager has received an unlock request from EJB:PortfolioMetaData with primary key:[ObjectPK: type: PortMetaData name: PortMetaData]. However, this primary key could not be found in the Lock Manager. This indicates either an EJB container bug, or the equals and hashCode methods for the primary key class:com.armanta.ejb.ObjectPK are implemented incorrectly. Please check the equals and hashCode implementations.
javax.ejb.EJBException: [EJB:010108]The EJB Lock Manager has received an unlock request from EJB:PortfolioMetaData with primary key:[ObjectPK: type: PortMetaData name: PortMetaData]. However, this primary key could not be found in the Lock Manager. This indicates either an EJB container bug, or the equals and hashCode methods for the primary key class:com.armanta.ejb.ObjectPK are implemented incorrectly. Please check the equals and hashCode implementations.
at weblogic.ejb.container.locks.ExclusiveLockManager$LockBucket.unlock(ExclusiveLockManager.java:409)
at weblogic.ejb.container.locks.ExclusiveLockManager.unlock(ExclusiveLockManager.java:170)
at weblogic.ejb.container.manager.ExclusiveEntityManager.afterCompletion(ExclusiveEntityManager.java:723)
at weblogic.ejb.container.manager.ExclusiveEntityManager.afterCompletion(ExclusiveEntityManager.java:667)
at weblogic.ejb.container.internal.TxManager$TxListener.afterCompletion(TxManager.java:984)
at weblogic.transaction.internal.ServerSCInfo.callAfterCompletions(ServerSCInfo.java:862)
at weblogic.transaction.internal.ServerTransactionImpl.callAfterCompletions(ServerTransactionImpl.java:2913)
at weblogic.transaction.internal.ServerTransactionImpl.afterCommittedStateHousekeeping(ServerTransactionImpl.java:2806)
at weblogic.transaction.internal.ServerTransactionImpl.setCommitted(ServerTransactionImpl.java:2851)
at weblogic.transaction.internal.ServerTransactionImpl.globalRetryCommit(ServerTransactionImpl.java:2650)
at weblogic.transaction.internal.ServerTransactionImpl.globalCommit(ServerTransactionImpl.java:2570)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:277)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:226)
at weblogic.ejb.container.internal.BaseEJBHome.postHomeInvoke(BaseEJBHome.java:389)
at weblogic.ejb.container.internal.EntityEJBHome.findByPrimaryKey(EntityEJBHome.java:408)
at com.armanta.ejb.portfolio.PortfolioMetaData_a4zvzk_HomeImpl.findByPrimaryKey(PortfolioMetaData_a4zvzk_HomeImpl.java:64)
at com.armanta.ejb.portfolio.PortfolioMasterBean.getPortfolioMetaData(PortfolioMasterBean.java:313)
at com.armanta.ejb.portfolio.PortfolioMaster_fmk9e8_EOImpl.getPortfolioMetaData(PortfolioMaster_fmk9e8_EOImpl.java:64)
at com.armanta.ejb.portfolio.PortfolioMaster_fmk9e8_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:517)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:407)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:403)
at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:56)
at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:934)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
I checked the equals and hashCode implementations and nothing pops out at me. Once this happens, the EJB seems to get messed up in the database and I lose information!
Here is the class implementation along with its superclass. I don't see anything blatant. Sorry for the lack of indentation, my original post was indented.
Thanks
Eric
public class ObjectPK extends ArmantaPK {
private String type;
private String name;
private ObjectPK() {
super();
public ObjectPK(String type, String name) {
super();
this.type = type;
this.name = name;
public String getName() {
return name;
public String getType() {
return type;
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[ObjectPK:");
buffer.append(" type: ");
buffer.append(type);
buffer.append(" name: ");
buffer.append(name);
buffer.append("]");
return buffer.toString();
* Returns <code>true</code> if this <code>ObjectPK</code> is the same as the o argument.
* @return <code>true</code> if this <code>ObjectPK</code> is the same as the o argument.
public boolean equals(Object o) {
if (this == o) {
return true;
if (!super.equals(o)) {
return false;
if (o == null) {
return false;
if (o.getClass() != getClass()) {
return false;
ObjectPK castedObj = (ObjectPK) o;
return ((this.type == null ? castedObj.type == null : this.type
.equals(castedObj.type)) && (this.name == null
? castedObj.name == null
: this.name.equals(castedObj.name)));
* Override hashCode.
* @return the Objects hashcode.
public int hashCode() {
int hashCode = super.hashCode();
hashCode = 31 * hashCode + (type == null ? 0 : type.hashCode());
hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode());
return hashCode;
public Object clone() {
ObjectPK inst = new ObjectPK();
inst.type = this.type == null ? null : new String(this.type);
inst.name = this.name == null ? null : new String(this.name);
return inst;
public abstract class ArmantaPK implements Serializable, Cloneable, Comparable {
// Enforce compatability with future versions
private static final long serialVersionUID = 1980721424128862564L;
// Cache the hash code
private transient int hash = 0;
* Clones a primary key. Note that this is not a deep copy.
* @return the cloned primary key
public Object clone() throws CloneNotSupportedException {
ArmantaPK newKey = (ArmantaPK) super.clone();
newKey.hash = 0;
return newKey;
* Compare the specified object with this key for equality.
* Implementations should return <tt>true</tt>
* if and only if the specified object is also a key
* of the same class and all corresponding attributes in the keys are
* <i>equal</i>.
* @param other the object to be compared for equality with this key.
* @return <tt>true</tt> if the specified object is equal to this key.
public boolean equals(Object other) {
return other instanceof ArmantaPK;
* This implementation only returns an empty String.
* @return String
public String toString() {
return "";
* Return the hash code value for this key. Implemented to call the
* key's <code>computeHash</code> method and cache the result for
* faster operation. Classes extending <code>ArmantaPK</code> should
* only implement <code>computeHash</code>.
* @return int
public int hashCode() {
if (hash == 0) {
hash = computeHash();
return hash;
* @y.exclude
* Compute a hash code for this key. This is the method that should
* be overridden by sub-classes.
* @return int
protected int computeHash() {
return 0;
* @y.exclude
* After called, will force the hash code to get recomputed.
public void rehash() {
hash = 0;
* Compares this <tt>ArmantaPK</tt> to another object by comparing
* their string representations.
* @return an integer based upon comparing the <tt>ArmantaPK</tt>s string
* representations
public int compareTo(Object o) {
return toString().compareTo(o.toString());
}We are experiencing a similar error after upgrading 9.2 to 9.2 MP3. We do not want to upgrade to 10g at this time. Is there a patch we can download with the fix?
-
Hi!
When i run my appication client to connect to Oracle9i database i have a next exception:
javax.ejb.CreateException: java.lang.IllegalStateException: Primary key not available.
In Oracle i set a primary key field ID.
Here is my code:
/* Generated by Together */
package ejb;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.EJBException;
import javax.ejb.CreateException;
import java.sql.SQLException;
import java.sql.Connection;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.sql.PreparedStatement;
import javax.ejb.NoSuchEntityException;
import java.sql.ResultSet;
import javax.ejb.DuplicateKeyException;
import javax.ejb.RemoveException;
import java.util.Collection;
import java.util.ArrayList;
import javax.ejb.FinderException;
import javax.sql.DataSource;
import java.lang.Integer;
import java.lang.String;
import java.rmi.RemoteException;
import javax.sql.*;
import java.sql.DriverManager;
public class TestingBean implements EntityBean {
private EntityContext ctx;
public Integer userID;
public String userLogin;
public String userPassword;
public String userPrivilege;
static private final String users_res_ref = "jdbc/Oracle";
public void setEntityContext(EntityContext context) throws EJBException {
System.out.println("EntityContext before = " + ctx);
ctx = context;
System.out.println("EntityContext after = " + ctx);
public void unsetEntityContext() throws EJBException {
ctx = null;
public void ejbActivate() throws EJBException {
public void ejbPassivate() throws EJBException {
public void ejbRemove() throws EJBException {
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
userID = (Integer)ctx.getPrimaryKey();
ps = con.prepareStatement("DELETE FROM TLogon WHERE Id = ?");
ps.setInt(1, userID.intValue());
if (!(ps.executeUpdate() > 0)) {
throw new RemoveException ("ejbLoad: Can't remove user - " + userID);
catch (Exception e) {
throw new EJBException(e);
finally {
closeStatement(ps);
closeConnection(con);
public void ejbStore() throws EJBException {
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
ps = con.prepareStatement("UPDATE TLogon SET Login = ?, Password = ?, Privilege = ? WHERE Id = ?");
ps.setString(1, userLogin);
ps.setString(2, userPassword);
ps.setString(3, userPrivilege);
ps.setInt(4, userID.intValue());
ps.executeUpdate();
catch (Exception e) {
throw new EJBException(e);
finally {
closeStatement(ps);
closeConnection(con);
public void ejbLoad() throws EJBException {
Connection con = null;
PreparedStatement ps = null;
userID = (Integer)ctx.getPrimaryKey();
try {
con = getConnection();
ps = con.prepareStatement("SELECT Id, Login, Password, Privilege FROM TLogon WHERE Id = ?");
ps.setInt(1, userID.intValue());
ps.executeQuery();
ResultSet rs = ps.getResultSet();
rs.next();
userLogin = rs.getString("Login");
userPassword = rs.getString("Password");
userPrivilege = rs.getString("Privilege");
catch (Exception e) {
throw new EJBException("ejbLoad: Can't load user - " + userID);
finally{
closeStatement(ps);
closeConnection(con);
public Integer ejbCreate(Integer aUserID, String aUserLogin, String aUserPassword, String aUserPrivilege) throws CreateException, EJBException, SQLException {
System.out.println("Inititialization parameters...");
this.userID = aUserID;
this.userLogin = aUserLogin;
this.userPassword = aUserPassword;
this.userPrivilege = aUserPrivilege;
System.out.println("Setting connection to null...");
Connection con = null;
PreparedStatement ps = null;
try {
System.out.println("Getting connection...");
con = getConnection();
System.out.println("EntityContext before getting primary key... = " + ctx);
System.out.println("Getting primary key...");
userID = (Integer)ctx.getPrimaryKey();
System.out.println("Primary key is done...");
ps = con.prepareStatement("INSERT INTO TLogon (Id, Login, Password, Privilege) VALUES (?,?,?)");
System.out.println("Inserting data...");
ps.setInt(1, userID.intValue());
ps.setString(2, userLogin);
ps.setString(3, userPassword);
ps.setString(4, userPrivilege);
ps.executeUpdate();
return aUserID;
catch (Exception e) {
throw new CreateException(e.toString());
finally{
closeStatement(ps);
closeConnection(con);
public Integer ejbFindByPrimaryKey(java.lang.Integer pk) throws FinderException, EJBException {
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
ps = con.prepareStatement("SELECT Id, Login, Password, Privilege FROM TLogon WHERE Id = ?");
ps.setInt(1, pk.intValue());
ps.executeQuery();
ResultSet rs = ps.getResultSet();
rs.next();
return pk;
catch(Exception e) {
throw new FinderException (e.toString());
finally {
closeStatement(ps);
closeConnection(con);
public void ejbPostCreate(Integer aUserID, String aUserLogin, String aUserPassword, String aUserPrivilege) throws CreateException, EJBException, SQLException {
/* Write your code here */
public Collection ejbFindAllUsers() throws EJBException, FinderException {
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
ps = con.prepareStatement("SELECT Id FROM TLogon");
ps.executeQuery();
ResultSet rs = ps.getResultSet();
ArrayList v = new ArrayList();
Integer pk;
while(rs.next()) {
pk = new Integer(rs.getInt(1));
v.add(pk);
return v;
catch(Exception e) {
throw new FinderException(e.toString());
finally {
closeStatement(ps);
closeConnection(con);
public Integer getUserID() throws RemoteException, EJBException {return userID;}
public void setUserID(Integer param) throws RemoteException, EJBException {this.userID = param;}
public String getUserLogin() throws RemoteException, EJBException {return userLogin;}
public void setUserLogin(String param) throws RemoteException, EJBException {this.userLogin = param;}
public String getUserPassword() throws RemoteException, EJBException {return userPassword;}
public void setUserPassword(String param) throws RemoteException, EJBException {this.userPassword = param;}
public String getUserPrivilege() throws RemoteException, EJBException {return userPrivilege;}
public void setUserPrivilege(String param) throws RemoteException, EJBException {this.userPrivilege = param;}
private Connection getConnection() throws SQLException {
InitialContext initCtx = null;
try {
initCtx = new InitialContext();
DataSource ds = (javax.sql.DataSource)initCtx.lookup("java:comp/env/" + users_res_ref);
return ds.getConnection();
catch (Exception e) {
throw new EJBException(e);
private void closeStatement(PreparedStatement ps) {
try {
if (ps != null) {ps.close();}
catch (Exception e) {
throw new EJBException(e);
private void closeConnection(Connection con) {
try {
if(con != null) {con.close();}
catch(Exception e) {
throw new EJBException(e);
What i do wrong?
Please help!!!!Very BIG thank you!!!!
That's right, but i must delete this method only in ejbCreate?
And i have a next exception: java.sql.SQLException: ORA-00947: not enough values. Why?
Here is my code db:
CREATE TABLE "SYSTEM"."TLOGON" ("ID" NUMBER(20) NOT NULL, "LOGIN"
VARCHAR2(20 byte) NOT NULL, "PASSWORD" VARCHAR2(20 byte) NOT
NULL, "PRIVILEGE" VARCHAR2(20 byte) NOT NULL,
CONSTRAINT "ID" PRIMARY KEY("ID")
USING INDEX
TABLESPACE "SYSTEM"
STORAGE ( INITIAL 12K NEXT 12K MINEXTENTS 1 MAXEXTENTS
2147483645 PCTINCREASE 50 FREELISTS 1 FREELIST GROUPS 1)
PCTFREE 10 INITRANS 2 MAXTRANS 255)
TABLESPACE "SYSTEM" PCTFREE 10 PCTUSED 40 INITRANS 1
MAXTRANS 255
STORAGE ( INITIAL 12K NEXT 12K MINEXTENTS 1 MAXEXTENTS 249
PCTINCREASE 50 FREELISTS 1 FREELIST GROUPS 1)
LOGGING
And my client:
package ejb.client;
import javax.naming.Context;
import javax.rmi.PortableRemoteObject;
import ejb.TestingHome;
import ejb.Testing;
import java.util.Collection;
import java.rmi.RemoteException;
import javax.ejb.FinderException;
import javax.naming.InitialContext;
public class TestingClient {
public static void main(String []args) {
try {
System.out.println("Step #1");
Context initial = new InitialContext();
System.out.println("Step #2");
Object objref = initial.lookup("java:comp/env/ejb/SimpleTesting");
System.out.println("Step #3");
ejb.TestingHome home = (ejb.TestingHome)PortableRemoteObject.narrow(objref, ejb.TestingHome.class);
System.out.println("Step #4");
ejb.Testing aTesting;
for(int i = 0; i < 3; i++) {
String login = users[0];
String password = users[i][1];
String privilege = users[i][2];
System.out.println("Adding user..." + login + "\n" + password + "\n" + privilege);
home.create(new Integer(i+1), login, password, privilege);
Integer i = new Integer(2);
home.create(i, "Zatoka", "password", "admin");
catch(Exception e) {
e.printStackTrace();
//private static String JNDI = "ejb.TestingHome";
private final static String[][] users = {{"Zatoka","*****","admin"}, {"Ivanov","234fds","user"},{"Petrov","dcd2","user"}};
BIG thanks!!! -
Exception: non-read-only mapping defined for the primary key field
Hello.
I'm new to Oracle and I created Java EE Web Project.
And I created entities from tableA, tableB, tableC from my database.
tableA has foreign key to tableB and has unidirectional Many-to-One relationship. tableC has two primary keys and one of these is foreign key to primary key in tableA. tableC also has unidirection Many-to-One relationship to tableA.
Then I created session bean and data control from it, in design window, created read-only table from tableA.
And I selected columns in tableA and also in tableB.
I ran the application and saw the following exception in log window.
Local Exception Stack:
Exception [EclipseLink-46] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: There should be one non-read-only mapping defined for the primary key field [tableC.tableA_ID].
Descriptor: RelationalDescriptor(mypack.tableC --> [DatabaseTable(tableC)])
tableA_ID is a primary key in tableA.
How can I solve this error?
Please help me.
Edited by: 900471 on 2011. 12. 3 오전 5:32
Edited by: 900471 on 2011. 12. 3 오전 5:33
Edited by: 900471 on 2011. 12. 3 오전 5:33
Edited by: 900471 on 2011. 12. 3 오전 5:34There are not enough details to be sure since you have not provided the mappings. From just the error, it looks like you are using the tableC.tableA_ID field as the foreign key in the ManyToOne relationship to A, but have marked it as insertable=false, writeable=false, meaning that it cannot be updated or used for inserts.
Either make it writable (set the settings to true), or add another basic mapping/attribute in the entity for TableC that maps to the field which you can use to set when you insert a new tableC entity. A simple example is available at
http://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/DerivedIdentifiers
Best Regards,
Chris
Maybe you are looking for
-
How to find out the standard info stucture for a customized IS in LIS
Hi All I have to run the statistical set up for the customized info structure S763 for the application plant maintenance in LIS. But i dont know whether it was copied from a standard SAP info structure or it was enhanced from a standard info structur
-
How to Change Allocation type in tablespaces?
How i can change the allocation type in tablespaces As Source database the table spaces are- SQL> select tablespace_name, status,allocation_type from dba_tablespaces; TABLESPACE_NAME STATUS ALLOCATIO SYSTEM ONLINE USER UNDOTBS1 ONLINE SYSTEM TEMP ONL
-
Removing items from sheet doesn't change SQL
Discoverer desktop 10.1.2.1 When I create a sheet, run it, then remove items from the sheet, and then refresh it, the SQL doesn't change (items/columns that were removed remain in the select statement). They (columns) are removed from the resulting r
-
Hi experts, i am creating saled order for customer who is in canada, but am getting error message is pricing error:mandatory condition mwst is missing. sometime back no error is getting for canada and got 0% on that time. Now we r getting this error
-
Relation between Enterprise Business Functions and ES Bundles
Hello Is there a way to identify the Enterprise Business Function corresponding to an Enterprise Service Bundle. I need to get some services activated from an ES Bundle, but not able to locate the corresponding Enterprise Business Functionlaity in SF