Problem in a composite primary key
I have a CMP Entity Bean which has two dependent objects which have siple primary keys, but that EntityBean needs the primary key of that objects to be referenced and identify. What is the way to perform it?
any help pleased.
Thank you.
Hi,
I understand your question as follows. You have 3 entity beans eb1, eb2 and eb3. You have primary key pk1 for eb1 and primary key pk2 for eb2. These two keys are part of eb3, and together they should be the primary key for eb3.
What I always do in those cases is to add an additional field to eb3 and concatenate pk1 and pk2. This is specifically easy when pk1 and pk2 are Strings. Perhaps this is not the best way, but I find it very useful, as it is very easy when your primary key is stored in only one field.
Hope this helps, Sponiza
Similar Messages
-
Deployment Tool Problem (J2EE -Composite primary Key Class)
Hi !!
e.g. I have an entiybean which has composite primary key class. So while deploying in J2EE tool u need to specify the Primary key class and the primary key field. well in case of a composite primary key class(if u have more than one field)...how do u declare all the fields for primary key class....
if u r not getting me please tell me... See in J2EE deployment tool there is on section called Entity..in that see the Primary Key class (there u specify the Primary key class) and the Primary Key Field Name (the field name) Here u can just give only one Field name..if you have mulitple fields, then where you will specify... Please let me know..
if anybody wants the code I will give the code...Please try to help..(how to deploy this kind of entity bean in J2EE deployment tool)
-BhumikaHi Bhumika,
in case you have more than one field you need to write a Primary key class where the fields you want to be the key are member variables.
your p.key class could look like this (it has to implement hash() and equals() ):
public class PersonPK implements java.io.Serializable
public int person_ID;
public PersonPK()
public PersonPK(int aPersonId)
person_ID = aPersonId;
public int hashCode()
return person_ID;
public boolean equals(Object ob)
if (ob == this) return true;
if (!(ob instanceof PersonPK)) return false;
PersonPK other = (PersonPK) ob;
if (person_ID != other.person_ID) return false;
return true;
-Hope this helps a bit,
Anke -
Error While Deploying A CMP Entity Bean With A Composite Primary Key
Hello all,
I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
[05/Jan/2005:12:49:03] WARNING ( 1896): Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
Update the type of the key class field.
Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
Please let me know if you need more information to answer my question.
Thanks.
NikolaHi Nikola,
There are several problems with your CMP bean.
1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
Do you try to use stubs instead of relationships or for some other reason?
If it's the former - look at the CMR fields.
If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
the CMP container generates the PK values, use the Unknown
PrimaryKey feature.
Regards,
-marina -
I am using Sun One App Server PE8.
I have a class with a composite primary key field. When I place the following method in my Home interface:
public MyEjb findByPrimaryKey(MyEjbPrimaryKey pk) throws FinderException, RemoteException;I get the following error when deploying:
ejbFindByPrimaryKey(EjbPrimaryKey) is already defined in MyEjb1368202910_ConcreteImpl
public MyEjbPrimaryKey ejbFindByPrimaryKey (MyEjbPrimaryKey key)However, If i remove this method from the Home interface, i get the following error when running the verification tool:
Error: No single arg findByPrimaryKey(PrimaryKeyClass) method was found in home interface class [ MyEjb ].However, I can still deploy the EAR successfully.
Another related symptom of this problem, is if I include the following method in my Home interface:
public MyEjb findByPrimaryKey(String pkField1, String pkField2) throws FinderException, RemoteException;And call this method, I get the following exception at runtime:
java.rmi.RemoteException: Bean class for ejb [MyEjb] does not define a method corresponding to [Home] interface method [public abstract MyEjb MyEjbHome.findByPrimaryKey(java.lang.String,java
.lang.String) throws javax.ejb.FinderException,java.rmi.RemoteException]I get these same problems with all EJB's that use composite keys. Has anyone else had this problem?
Thanks
tobyThis is a CMP bean, with no ejbFindByPrimaryKey in the Bean class. Below, i have included the Home interface and the Bean class (with unneccessary code removed)
Thanks for looking at this for me.
BEAN CLASS
package lands.mc.bus.prod;
import java.rmi.*;
import java.util.*;
import javax.ejb.*;
public abstract class TopoMapBean implements EntityBean
private EntityContext entity;
public TopoMapBean()
public void setEntityContext(EntityContext ctx)
entity = ctx;
public void unsetEntityContext()
entity = null;
public TopoMapPrimaryKey ejbCreate(String mapName, String mapNumber, String mnemonic,String edition, String scale)
throws CreateException
// call setters...
return null;
public void ejbPostCreate( String mapName,
String mapNumber,
String mnemonic,
String edition,
String scale )
removed set/get methods
public void ejbStore() {}
public void ejbLoad() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
}HOME INTERFACE
package lands.mc.bus.prod;
import java.rmi.*;
import java.util.*;
import javax.ejb.*;
public interface TopoMapHome extends EJBHome
public TopoMap create(String mapName,
String mapNumber,
String mnemonic,
String edition,
String scale
throws CreateException, RemoteException;
public TopoMap findByPrimaryKey(String mapNumber, String edition) throws FinderException, RemoteException;
// doesnt deploy with this signature
// public TopoMap findByPrimaryKey(TopoMapPrimaryKey pkey) throws FinderException;
// have to use this method instead of findByPrimaryKey(String, String) above
public TopoMap findTopoMap(String mapNumber, String edition) throws FinderException, RemoteException; -
Null in Composite Primary Key and "Primary keys must not contain null"
Hello all.
I'm a newbie concerning to JPA/EJB3, but I was wondering if toplinks doesn't support composite primary keys with null in some field (something perfectly right in any RDBMS).
I used JDeveloper (I'm using Oracle 10g database and JDeveloper 10.1.3.2.) wizards to generate JPA classes and I checked out generated files (with annotations), so they should be right (by the way, other O-R mappings for my model are working right, but this one).
I'm getting the next error:
Exception Description: The primary key read from the row [DatabaseRecord(
TSUBGRUPOSLDI.CD_GRUP => 01
TSUBGRUPOSLDI.CD_SUBGRUP => null
TSUBGRUPOSLDI.CG_POBL => 058
TSUBGRUPOSLDI.CG_PROV => 28
TSUBGRUPOSLDI.DSCR => Sanidad)] during the execution of the query was detected to be null. Primary keys must not contain null.
Compound primary key is (CD_GRUP, CD_SUBGRUP). No foreign keys, no joins (only a NamedQuery: "select o from ..."). It's the simplest case!
I checked out that everything runs ok if there's no "null" value in CD_SUBGRUP.
After some research (this and other forums) I'm beginning to believe that it's not supported, but not sure.
Am I doing sth wrong? If not, what is the reason to not support this? Will it be supported in the future?
Thanks in advance.Null is a special value and in many databases is not comparable to another null value (hence the isNull operator) and may pose problems when used to uniquely identify an Entity. TopLink does not support null values within a composite PK. As the nullable column is most likely not designated as a PK within your database table (many databases do not allow this) I recommend updating the Entity PKs to match that of the database.
--Gordon -
Master Detail Forms with 2 composite primary keys - Is there a workaround?
Hello All,
I have been searching for a workaround to the maximum 2 part primary key restriction on the multi-row updates, and master-detail forms, and am hoping that someone can help me. I am using HTMLDB v2.0.0.00.49 with IE 6 against a 9.2 DB.
I successfully implemented the workaround of Fred Stoopendaal's (see Updata PK on HTML DB ) and it works fine for single page multi-record updateable forms, but alas I haven't been able to extend it to master detail forms (I think it is something to do with Oracle not allowing the "returning" clause on views).
Here is what I tried:
two tables, one with a 2 part composite primary key, which is the master table, and a detail table with 3 part composite primary key -
--------- BEGIN SQL ---------
create table master_table
( master_col1 number
, master_col2 number
, master_col3 varchar2(30)
, constraint master_pk primary key (master_col1,master_col2));
create table detail_table
(detail_col1 number
,detail_col2 number
,detail_col3 number
,detail_col4 varchar2(30)
, constraint detail_pk primary key(detail_col1,detail_col2,detail_col3)
, constraint master_detail_fk foreign key (detail_col1,detail_col2) references master_table(master_col1,master_col2));
create or replace view v_master_table as
select rowid mata_rowid,mata.*
from master_table mata;
create or replace view v_detail_table as
select rowid deta_rowid,
(select rowid from master_table mata where mata.master_col1 = deta.detail_col1 and mata.master_col2 = deta.detail_col2) deta_mata_rowid
, deta.*
from detail_table deta;
create or replace trigger mata_ins_upd_trg
instead of insert or update on v_master_table
referencing new as new old as old
for each row
begin
if inserting then
insert into master_table (master_col1, master_col2, master_col3)
values (:new.master_col1, :new.master_col2, :new.master_col3);
end if;
if updating then
update master_table
set master_col1 = :new.master_col1,
master_col2 = :new.master_col2,
master_col3 = :new.master_col3
where rowid = :old.mata_rowid;
end if;
end;
create or replace trigger deta_ins_upd_trg
instead of insert or update on v_detail_table
referencing new as new old as old
for each row
begin
if inserting then
insert into detail_table ( detail_col1, detail_col2, detail_col3, detail_col4)
values (:new.detail_col1, :new.detail_col2, :new.detail_col3, :new.detail_col4);
end if;
if updating then
update detail_table
set detail_col1 = :new.detail_col1,
detail_col2 = :new.detail_col2,
detail_col3 = :new.detail_col3,
detail_col4 = :new.detail_col4
where rowid = :old.deta_rowid;
end if;
end;
--------- END SQL ---------
Then I created a master-detail form in Apex on the two views, using the mata_rowid and deta_rowid as primary keys, and mata_rowid=deta_mata_rowid as the link. I realise that using a function to fetch the master rowid within the detail view query is costly, but it was my intention to modify the record fetch queries to use the real FK columns once things were up and running.
It seems to generate the pages ok, and I can insert/update master table records, but as soon as I modify records in the detail table things go a bit haywire. I can't find any documentation on how the inbuilt MRU/MRD logic works, so can't figure out the issue.
Can anyone out there tell me what the problem is with the logic above, or if they have come up with a neat solution to this annoying limitation. I know that many will say that I should modify the data model to use surrogate primary keys, but many of the uses for HTMLDB are new interfaces for old schemas, so a workaround that doesn't involve wholesale data model changes would be preferable.
Thanks in advance,
Mike CretanHi, this is likely not the most elegant way...but perhaps the simplest -- and I didn't have much time to play.
I used Wizard to create two separate Master Detail forms, each with a separate detail table. Thus I ended up with four pages:
Page "A" - "Selector" page for Master (Report), with Edit link driving to Detail-1
Page "B" - Editable Master/Detail-1 page (HTML / Report)
Page "C" - "Selector" page for Master (Report), with Edit link driving to Detail-2
Page "D" - Editable Master/Detail-2 page (HTML / Report)
Then I selected the primary key column TWICE on the Report on Page A. Modified the second instance of this column to navigate to Page D (passing primary key) exactly the way the original instance of this column navigates to Page B. Then I deleted Page C.
Since you can have only one Tabular Entry form per page, this seemed the best way to drive two separate detail tables from a common interface. -
Multiple composite primary key in Master Table
Dears ,
I am try to find any solution about Multiple composite primary key by search in forum , but i didn't success ... i am try to built master detail , the master structure table built with multiple composite primary key , i know that apex 4.2 still support tow primary key , in detail table i solved the problem by depend on rowid , and now i can use multiple composite primary key in detail table , the problem with master table because it's support only tow primary key , there are any solution by manual process or any something else ?
Thanks
Abo YahyaHi,
I've never done this so all I can do is give some suggestions. It takes more effort because you are going beyond what APEX currently supports. That said, you might try searching the forum with this search string:
key AND table AND instead
Make sure the ANDs are capitailized in the search criteria. Also, look at this thread {thread:id=395870} and the forum thread asociated with this message {message:id=10542916}.
Best wishes,
Howard -
Composite Primary key & Primary key questions
Background:
1.5 TB data warehouse. All tables use at least a 3 column composite Primary key. Most use 3. col1||col2||col3 to achieve uniqueness.
col1= very low cardinality. 99% of the values are '0'
col2 = high cardinality. (SSN's, loaded monthly)
col3 = low cardinality. (monthly sequence number used for partitioning)
From what I've read, the first column used in a composite primary key also receives its own index. If that is correct, then the primary key being used is losing its effectiveness by putting a very low cardinality column as the first column of the Primary key. By moving col2 to the first position of the composite key, I would be obtaining an index on SSN which would be much more useful. (Please correct me if I'm wrong) Or since the index would be so large anyway, the CBO would just do full table scans which is what I'm trying to get away from.
This Primary key is used to ensure uniqueness during loads. Other than that, it really has no purpose and is never queried by the user. (WHERE col1||col2||col3 = xxxxxxxxx)
As a DBA, I see this massive tablespace for holding the primary keys now reaching in excess of 157 GB and it seems like such a waste of space. The problem I'm running across is how to ensure uniqueness during the loads w/o having to store the unique values. (the 157 GB) If I drop the PK's, then create unique indexes just for the loads, then the unique index would be generated against the entire table, which would take forever.
If you create a local index (what I want in the end) it still has to create the index for all previous partitions (250+ partitions). You can't create a specific 'local' index on a partition. You create a local index on the table and when a new partition is added, the index is then added as well. That's what I want to do with some of my fields like SSN but for loading purposes, this isn't going to help me.
I need a way to ensure uniqueness during a monthly load of a new partition (col1||col2||col3) but w/o having to store these values for eternity. Right now it's the primary key, so it has to be stored. I hope I'm making sense here. Any ideas?I think you need some clarification about the index supporting the primary key.
The primary key is unique - the database will enforce this for you.
All of the columns in the primary key are in the index that enforces the key (not just the first column).
Usually this index is a unique index, but you can have a non-unique index supporting a primary key.
I'm a little confused with some of your other statements
how to ensure uniqueness during the loads w/o having to store the unique valuesIf you don't store the value how do you know it is unique?
Did you mean that you don't want to store the key values in both the table and the index?
You may want to consider making col3 (the partition key) the leading column of the index, so you can create a local (instead of global) PK index.
I wouldn't worry too much about col1 (the column full of mostly zeros) - numbers are stored variable length. A NUMBER(38) that holds a zero takes no more space than a NUMBER(1) that holds a zero. -
Composite primary key as foreign key not working
i want have two tables
in one table i make a composite primary key
and in the other table i refer one of the column of the composite key from the above table as foreign key in this table but this didn't work.
eg:
create table temp1
( name char2(10),
ssn# number(10)
address varchar2(10)
constraint (cons_1)primary key(name,ssn#) );
create table temp2
( name1 char2(10) references temp1(name),
add varchar(20));
this didn't work....can't create temp2 table it's giving errorThe following includes some corrections and some suggestions. Your original code had several problems: missing comma, invalid name, invalid data type, no unique key for the foreign key to reference. The following fixes all of those and adds some meaningful names for the constraints and formats it so that it is easier to read.
CREATE TABLE temp1
(name VARCHAR2 (10),
ssn# NUMBER (10),
address VARCHAR2 (10),
CONSTRAINT temp1_name_ssn#_pk
PRIMARY KEY (name, ssn#),
CONSTRAINT temp1_name_uk
UNIQUE (name))
Table created.
CREATE TABLE temp2
(name1 VARCHAR2 (10),
address VARCHAR2 (20),
CONSTRAINT temp2_name1_fk
FOREIGN KEY (name1)
REFERENCES temp1 (name))
Table created. -
Hi all,
I am new to ejb. I am trying to create a BMP bean for a particular table which is having composite primary key. I made a primary key class for that and I have done all the important things required for creating such a class viz,
1) implement java.io.Serializable
2) define all fields of the primary key as public variables in the class
3) override public int hashCode()
and public boolean equals (Object obj)
but when i deploy the beans in jboss it is giving
"The primary key class must override equals()" error
what could be the problem
Thanks in advance
BinnyAdd a method boolean equals(Object o) see java.lang.Object. This is required for comparisons, also hashCode needed.
-
Hi, I have a table which maintains versions. This has a composite primary key - eg - Company_id + version_no. I tried creating a form based on a template with Primary key as Company_id and primary key column 2 as Version_no. When I try to run the form it gives an error, 'Invalid number' on the process in Rendering page. When i remove the second primary key the results are displayed correctly (however I have a problem when there are more than 1 versions - too many rows).
How do I create a form based on a template with a composite key.
How can I create a form which has more than 2 keys as part of a composite primary key.This thread is old....but let me make some notice...
Oracle guys,
does all that mean that you encourige using simple PK which is based on sequence, regardless that involve unique index on columns that normaly represent PK, but in master detail wizard it is impossible to use composite keys?
Why I'm asking this?
Because many apps are translated to HTMLDB (Oracle based) directly with not too much problems. But if we have to change PK then many things are complicated...
This all come from a problem how to fill detail table PK where first coulmn represent master key field and second one is filled with user input-nothing can be automated.
In your demo I saw that for "orders-order items" you use "simple PK" technique, regardless order items could have PK made from (OrderId, Id)...
Please make some respond for this....
THX! -
Creation of CMP bean for a Composite Primary key????
Hi
i am having a composite primary keys in one of my table in the database.
I am trying to create a new entity bean for this table but i don't know how to create one in case when there is a composite primary key for a table.
Can anybody let me know is it possible to do it.
what is the procedure to be followed for the creation of the Entity bean in case of a composite primary key.
I am using MySql as the database .Creating CMP type of Entity bean.
Any help in this regard will be greatly useful to me as this is very urgent.
Thanks & Regards
Vikram KHi Nikola,
There are several problems with your CMP bean.
1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
Do you try to use stubs instead of relationships or for some other reason?
If it's the former - look at the CMR fields.
If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
the CMP container generates the PK values, use the Unknown
PrimaryKey feature.
Regards,
-marina -
How to persist an entity with Composite primary key
Problem Statement:-
Entity A have many to one relation with Entity C
Entity B have many to one relation with Entity C
Entity C have a composite primary key of (Entity A PK & Entity B PK)
A --< C
B --< C
the entites are automatic generated by Dali tool
@Entity
public class C implements Serializable
@EmbeddedId
private C.PK pk;
private int attribute;
//Code
@Embeddable
public static class PK implements Serializable
public int A_Id;
public int B_Id;
//Code
@Entity
public class A implements Serializable
@Id
private int AId;
@OneToMany
private Set<C> C_Collection;
//Code
@Entity
public class B implements Serializable
@Id
private int BId;
@OneToMany
private Set<C> C_Collection;
//Code
i made a session Bean which add a new entity C
Session
A a = em.find(A.class, AId);
B b = em.find(B.class, BId);
C c = new C();
C.PK pk = new C.PK();
pk.AId(a.getID());
pk.BId(b.getID());
c.setPk(pk);
c.setA(a);
c.setB(b);
c.setAttribute(12);
em.persist(c);
when running this code an exception is raised
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'A_ID' in 'field list'Error Code: 1054
Call:INSERT INTO C (attribute, Aid, A_ID, B_ID, Bid) VALUES (?, ?, ?, ?, ?)
bind => [2, 6, 6, 1, 1]
this is logic as Table "C" has only 3 coloumns only "attribute" , "Aid" , "Bid"
but the mapping is different as it adds the composite PK attributes to the insert statement
if there is a sample code or how to solve this issue it would be greatHello Juwen,
The problem is you are registering an object, assigning it a null pk, and then commiting the uow/transaction. TopLink uses registered objects to keep track of changes you make inorder to persist those changes on commit. So the simple fix is to not commit the UnitOfWork - call release() on it instead.
Another solution is to use the session copyObject api. The simple form that only takes an object will work similar to registering the object as it will copy all persistent attributes but it will leave the primary key null. You can also use this method to specify a copyPolicy to customize the process. Using this method will be a bit more efficient, since a UOW makes both a working copy and a back up copy of objects registered, inorder to keep track of changes. Using the copyObject api will only make a single copy.
Best Regards,
Chris -
How to Work with Composite Primary Key
Hi All,
I'm working with Toplink JPA. Here I have A problem with inserting into database table which have composite Primary Key.
What I'm doing is, I have two tables. to maintain many to many relation between these two tables I created another intermediate table which consists of foreign Keys (reference) of above two tables.
Now these two foreign Keys in the Intermediate table made as composite Primary Keys.
When I'm trying to the data in the Intermediate table I'm getting the foreign Keys values are null..
could anyone suggest me how to work with composite Primary Keys
Thanks,
SatishI have the same problem, I have 3 tables with a join table joining them all. I have created an intermediate table entity. When I go to create a an entry, it says that I cannot enter null into "ID". Here is the SQl toplink generates:
INSERT INTO Z_AUTH_USER_AUTHORIZATION (CONTEXT_ID, AUTHORIZATION_ID, USER_ID) VALUES (?, ?, ?)
bind => [null, null, null]
Here are the classes:
-----------------------Join Table-----------------------------------------------
@Entity()
@Table(name = "Z_AUTH_USER_AUTHORIZATION")
public class AuthUserAuthorization implements Serializable{
@EmbeddedId
private AuthUserAuthorizationPK compId;
// bi-directional many-to-one association to AuthAuthorization
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "AUTHORIZATION_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
private AuthAuthorization authAuthorization;
// bi-directional many-to-one association to AuthContext
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "CONTEXT_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
private AuthContext authContext;
// bi-directional many-to-one association to AuthUser
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "USER_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
private AuthUser authUser;
---------------------------------------User table--------------------------------------------------------------
@Entity()
@Table(name = "Z_AUTH_USER")
public class AuthUser implements Serializable, IUser{
@Id()
@SequenceGenerator(name = "AUTH_USER_ID_SEQ", sequenceName = "Z_AUTH_USER_ID_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTH_USER_ID_SEQ")
@Column(name = "ID", unique = true, nullable = false, precision = 10)
private Integer id;
// bi-directional many-to-one association to AuthUserAuthorization
@OneToMany(mappedBy = "authUser", fetch = FetchType.EAGER)
private java.util.Set<AuthUserAuthorization> authUserAuthorizations;
-----------------------------------Context table-----------------------------------------------------------------
@Entity()
@Table(name = "Z_AUTH_CONTEXT")
public class AuthContext implements Serializable, IContext{
@Id()
@SequenceGenerator(name = "AUTH_CONTEXT_ID_SEQ", sequenceName = "Z_AUTH_CONTEXT_ID_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTH_CONTEXT_ID_SEQ")
@Column(name = "ID", unique = true, nullable = false, precision = 8)
private Integer id;
// bi-directional many-to-one association to AuthUserAuthorization
@OneToMany(mappedBy = "authContext", fetch = FetchType.EAGER)
private java.util.Set<AuthUserAuthorization> authUserAuthorizations;
----------------------------Authorization table-------------------------------------------------
@Entity()
@Table(name = "Z_AUTH_AUTHORIZATION")
public class AuthAuthorization implements Serializable, IAuthorization{
@Id()
@SequenceGenerator(name = "AUTH_AUTHORIZATION_ID_SEQ", sequenceName = "Z_AUTH_AUTHORIZATION_ID_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTH_AUTHORIZATION_ID_SEQ")
@Column(name = "ID", unique = true, nullable = false, precision = 8)
private Integer id;
// bi-directional many-to-one association to AuthUserAuthorization
@OneToMany(mappedBy = "authAuthorization", fetch = FetchType.EAGER)
private java.util.Set<AuthUserAuthorization> authUserAuthorizations;
I have tried to create the new entity several ways. I have tried to create one with the default constructor then set this entity on each of the other entities, I have also tried to pass in the entities to the join entity and set them there, but this doesn't work. Any help would be very appreciated!
Thanks,
Bill -
Update enrolled table which has 6 composite primary key
Hi Everyone,
I am trying to update a grade column in table called enrolled which has 6 composite primary key column including SID, TERMYEAR, FACCODE, DEPCODE, COURSENO, SECNO and 2 extra column including GRADE, IDD all of them are of type VARCHAR2 as describe below:
To update this table I used the command below:
UPDATE enrolled
SET grade = :COURSE_BLOCK.GRADE_TEXT
WHERE IID = :GLOBAL.logUserid
AND SID = :COURSE_BLOCK.SID_TEXT
AND FACCODE = :COURSE_BLOCK.FACULTY_TEXT
AND DEPCODE = :COURSE_BLOCK.DEPARTMENT_TEXT
AND COURSENO = :COURSE_BLOCK.COURSE_TEXT
AND SECNO = :COURSE_BLOCK.SECTION_TEXT;
Note: the :GLOBAL.logUserid is a global variable that I assigned the user id when the user log on to the application.
When I run the application and fill out the form in order to update the table this doesn't update the table and if I use SQL*PLUS as well with the values that I use for the form to update the table I get message: o rows updated
Can Someone help please?Here is the solution.
The problem:
The problem was that the enrolled table was designed in a way that a student can enrolled in the lecture(LEC type column) and Laboratory(LAB type column). When a student is given a grade, it is given a grade for the course 100 (eg: 03-60-100) this course has a lecture and lab. this course belong to the faculty code 03(science) department 60 (computer Science) so when a student register to a course, will register to a lecture and a lab but he will receive a grade for the course 100 lec in this case Oracle couldn't update the table because there was two column with course 100 for that particular student Id
The solution:
There are many solution I believe but my quickest solution is when a student register to the course by default is given a grade 'I' means Incomplete then when the instructor add the grade, he can just update a grade from incomplete to the final grade (eg A) now the code will be to get only the course 100 that has grade and discard that doesn't have grade this means that I need only to make sure that the WHERE Clause grade is not null shown below.
UPDATE enrolled
SET grade = BLOCK_NAME.FIELD_NAME
WHERE grade IS NOY NULL
AND IID = BLOCK_NAME.FIELD
AND faccode = BLOCK_NAME.FIELD
AND depcode = BLOCK_NAME.FIELD
AND courseno= BLOCK_NAME.FIELD_NAME
NAD secno = BLOCK_NAME.FIELD_NAME
AND SID = BLOCK_NAME.FIELD_NAME
Maybe you are looking for
-
Basically whenever I watch a video and I exit out of the video I have to restart my computer to get Firefox back open. If I exit out or go to a new page while the video is playing, the audio continues like nothing has happened. I've checked my task m
-
When I type in the address, my address bar disappears and I can't get it back
I amjus tnew to Macbookpro and I like seeing the web address that I have typed. Macbook pro seems to hide this info. I am sure it's a quick fix but I am frustrated and tired and just want an answer. What do I have to change to always see my ...wha
-
Multi-Touch still not work! MacBookPro 13' late 2013 model!
Sometimes in Safari,still crush and not work! My EFI is the latest 1.3! Always happen......."Two-finger swipe to navigate" always not working. I have to reboot my Macbook,after that everything will be fine.......
-
Cant burn to disc from itunes library
I am unable to burn music to disc it is saying a registry problem
-
Alv result send to External email adreess
hi, i want to send Alv grid result send to External email adreess.n e body help me how can i do this