SortedSet unique key problem

i want a SortedSet of patients. each has a unique id and a current heartRate .
i want to sort them by heartRate .
i am getting duplicate entries when the id is constant but the heartRate changes.
please consider this:
SortedSet<Patient>();
public class Patient {
  public int id;
  public int heartBeat;
public class PatientComparator implements Comparator {
  public int compare(Object obj1, Object obj2) {
    Patient p1 = (Patient) obj1; // <------- this downcast works... downcasts are illegal
    Patient p2 = (Patient) obj2; // yet how else can i write the Comparator? i don't get it.
    if(p1.heartBeat > p2.heartBeat) { return(1); }
    if(p1.heartBeat < p2.heartBeat) { return(-1); }
    return(0);
  public boolean equals(Object obj1, Object obj2) {
    Patient p1 = (Patient) obj1;
    Patient p2 = (Patient) obj2;
    return(p1.id == p2.id);
summary :
each time the same patient id has heartRate change, i get a new entry in the SortedSet .
the related issue, how could you write a Comparator without a downcast?

The equals method must be implemented in Patient class, not in PatientComparatori am still getting multiple entries even with this implementation:
public class Patient extends Object {
  public int id;
  public int heartBeat;
  public boolean equals(Object obj) {
    return(true);  // <---
}further, i am also implementing Comparator this way:
public class PatientComparator implements Comparator<Patient> {
  public boolean equals(Patient p1, Patient p2) {
    return(true); // <---
}and i still get multiple entries.
so, what method() does a Set use to guarantee that there are no duplicate entries?
and what key is used to uniquely identify an object in the Collection ?
when mySet.add((MyObj) myObj); i think the process should be:
(1) if myObj already exists in mySet remove it.
(2) add myObj to mySet .
for me, either step #1 is not happening, or there is something wrong with the keys .
i want to make the key patient.id .

Similar Messages

  • Problems Engineering Surrogate Primary Key with Unique Key

    SDDM 3.3.0.747 with 2 problems (at least so far).  I am hoping that the problem is with this SDDM rookie and I have overlooked some setting. PROBLEM 1 I don’t want to start a religious debate about surrogate vs. natural keys but I am having a problem engineering both correctly from the logical model.  I am a rookie when it comes to SDDM but have many years of experience with Designer. By default I like to have both a natural UID  (UK) and a surrogate key based primary UID (PK) which is used for foreign keys.  The problem I am having with engineering is I can successfully engineer the surrogate PK’s, engineer the FK’s using the PK’s but cannot get the unique key to contain the surrogate keys in the child table.  If I check the identifying property in the relations, the PK columns and the UK columns are included in the child PK and the UK contains no columns. The Setup I have defined two reference entities, PROBABILITY and SEVERITY with natural unique keys defined.  I also have a child entity RISK_ASSESMENT with relationships back to the PROBABILITY and SEVERITY entities and both have the “Use surrogate keys:”: check box checked.  The unique key for the RISK_ASSESMENT entity includes the relationships back to PROBILITY and SEVERITY.  None of the entities have a PK or surrogate key defined and they all have the “Create Surrogate Key” check box checked.  In addition the following preferences are set: Data Modeler/Model/Logical   NOT Checked - Use And Set First Unique Key As Primary Key   NOT Checked – Name – Keep as the name of the Originating attribute   Checked – Entity Create Surrogate Key   Checked – Relationship Use Surrogate Key PROBLEM 2 When the foreign key columns are engineered I want the names to have a prefix “FK_” but they don’t.  Templates are set as follows: Data Modeler/Naming Standard/Templates   Foreign Key:  FK_{child}{parent}   Column Foreign Key:  FK_{ref column} Engineer to Relational Model/General Options   Checked - Apply name translation Marcus Bacon

    I have been switching between SD 4 EA1 and SDDM 3.3 trying to get things to work and trying out the template table for adding audit columns (really nice!).
    Concerning Problem1.  No matter what settings I use and whether I use SDDM 3.3 or SDI cannot get the FK columns to be included in the UK even though the relations are included in the UID in the entitty.  When I open the properties of the child table and click on the naming standards button and click ok it complains that the UK is not complete.  I add the FK columns to the UK and all is well including the naming standards.
    Concerning Problem 2.  Sometimes it engineers the names for FK's from the template and sometimes it doesn't.  Didn't see a pattern.  Gave up trying and used Naming Standards button.  I still had to change a few.
    The good new is, that after make changes needed in UK's and Column names of 18 tables, I know have everything deployed to Test except FK Indexes.  I think I have to do those by hand.
    Marcus Bacon

  • Problem with unique key for Fiscal_T_Time dimension lookup

    Hi,
    In my mapping, I use Lookup on Fiscal_T_Time dimension provided by oracle. The validation gives me a warning,saying "VLD-1603:Lookup condition for key lookup Fiscal_T_Time does not contain a complete unique key". I'm using <source_group>.date as input and L_Day_day as lookup column, which is shown as I select the unique key from the drop down list. Both have type matches. The configuration on the dimension also shows the constraint of the unique Key. What can be wrong?

    Continue my issue in another thread by Daming Wang on "More constraints need to add to Dimension". Thanks.

  • Problem building unique key in create (AttributeList) after cancel create ?

    Hallo,
    i have a create form. In the create process i build a unique key.
    protected void create(AttributeList attributeList) {
    super.create(attributeList);
    try {
    String strSQL = "select max(ver_nr) from verfuegungen where sts_id = ?";
    PreparedStatement stmt = getDBTransaction().createPreparedStatement(strSQL,0);
    stmt.setInt(1,getStsId().intValue());
    ResultSet rs = stmt.executeQuery();
    rs.next();
    String snr = rs.getString(1);
    int inr = 0;
    if (snr != null)
    inr = Integer.parseInt(snr);
    inr = inr + 1;
    Number nnr = new Number(inr);
    setVerNr(nnr);
    The create process can be cancelled with the following method
    public String onCancelCreateVerfuegung() {
    BindingContainer bindings = getBindings();
    bindings.getOperationBinding("DeleteNewVerfuegung").execute();
    return "backpostdetails";
    When i initiated the create process after cancelling a second time, i've got JBO-25013.
    What can i do in the delete process that the error can't come?
    Any help is appreciated.

    Hi Claudio,
    well, I have an solution although it is neither nice nor clean...
    * Add a column Field2_notnull to Table B with not null-constraint and same type as Field2
    * Add a check-constraint to Table B like this: "nvl(Field2,'*') = Field2_notnull"
    * Create a UNIQUE KEY on Table B's Field1 and Field2_notnull and use this constraint for the MERGE-Load (INSERT/UPDATE)
    * Coming from Table A, use Field1 and nvl(Field2,'*') for the match
    As I said, neither nice nor clean, but it works, as long as you can manage to fill Field2_notnull in Table B correctly.
    Best regards
    Andreas

  • Unique Key Violation While Doing Multiple Updates And Create in EJB

    Hello All,
    I am using oracle 9i and Weblogic 7.0. I have a table that has a unique key constraint on one column , say 'Col1' and i am using a CMP to read,create and update data in this table. The problem description is as follows.
    I have JTable that display the data from the above said table. The user can modify the existing data and insert new data that will be reflected in the DB using the CMP. Let us say the following are displayed
    ROW1
    Col1 : 3
    Col2 : 'ABC'
    Col3 : 1 (Primary key in the table)
    Now the user modifies the above row and inserts a new record. Now the following will be the display
    ROW1 (Modified)
    Col1 : 4
    Col2 : 'ABC'
    Col3 : 1 (Primary key in the table)
    ROW2 (New)
    Col1 : 3
    Col2 : 'DEF'
    Col3 : 2 (Primary key in the table)
    When the above data is saved i do the following in the Code
    a) Session Bean
    For (all the data in the Jtable)
    try
    home.findByPrimaryKey(Col3);
    remote.update(Col1,Col2);
    catch(FinderException fe)
    home.create(Col1,Col2,Col3);
    When the above code is run During the first loop the update runs succesfully (i.e update old value of 3 with 4 ) but during the 2nd loop the create (i.e Insert new value 3) gives me the unique key violated exception. The following is the stack trace
    <Oct 25, 2004 11:36:22 AM IST> <Info> <EJB> <010049> <EJB Exception in method: ejbPostCreate: java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
    java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1892)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2130)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2013)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2869)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
    at weblogic.jdbc.jts.Statement.executeUpdate(Statement.java:509)
    at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.__WL_create(TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.java:1435)
    at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.ejbPostCreate(TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.java:1353)
    at java.lang.reflect.Method.invoke(Native Method)
    at weblogic.ejb20.manager.DBManager.create(DBManager.java:1023)
    at weblogic.ejb20.manager.DBManager.localCreate(DBManager.java:904)
    at weblogic.ejb20.internal.EntityEJBLocalHome.create(EntityEJBLocalHome.java:180)
    at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop_LocalHomeImpl.create(TerminalPaymentsCMP_kbdoop_LocalHomeImpl.java:73)
    at de.dl.ucs.contract.helperclasses.SubsegmentMaintanence.saveTerminalPayments(SubsegmentMaintanence.java:697)
    at de.dl.ucs.contract.controller.SubsegmentSL.saveSubsegmentDetails(SubsegmentSL.java:570)
    at de.dl.ucs.contract.controller.SubsegmentSL.processFinanceSubsegmentSave(SubsegmentSL.java:1601)
    at de.dl.ucs.contract.controller.SubsegmentSL_kgzv4j_EOImpl.processFinanceSubsegmentSave(SubsegmentSL_kgzv4j_EOImpl.java:498)
    at de.dl.ucs.contract.events.FinanceSubsegmentBEH.saveSubsegmentDetails(FinanceSubsegmentBEH.java:749)
    at de.dl.ucs.contract.events.FinanceSubsegmentBEH.processEvent(FinanceSubsegmentBEH.java:232)
    at de.dl.ucs.framework.flowcontroller.ControllerBean.delegateAction(ControllerBean.java:229)
    at de.dl.ucs.framework.flowcontroller.ControllerBean_riqvk4_EOImpl.delegateAction(ControllerBean_riqvk4_EOImpl.java:46)
    at de.dl.ucs.framework.flowcontroller.ControllerBean_riqvk4_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:441)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:382)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:726)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:377)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
    >
    <Oct 25, 2004 11:36:22 AM IST> <Info> <EJB> <010051> <EJB Exception during invocation from home: [email protected] threw exception: javax.ejb.TransactionRolledbackLocalException: EJB Exception:; nested exception is: java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
    Please help me with this, as far as i am concerned since both update and create is in the same transaction the update on the row must be visible to the create and hence there shouild not be any problem.....
    thanks in advance
    Shanki

    Hi,
    Thanks,
    There are 3 columns involved with that table . Out of whihc one is a Primary Key (string) , The other column (Number) has a unique key constraint defined on it and the last column stores a value corresponding to the 2nd column.
    The reason for me to do a create in the Finder exception is as follows.
    I Loop through the Data present in JTable. As given in the example let us assume that there are 2 rows in the JTable. Out of whihc the First row needs an updation and the second row , which is a new row needs to be created. So During the First iteration of the loop, The findermethod does not throw any exception (Because it is a modfied row) and hence the update gets fired successfully. During the second iteration , since it is a new row the findermethod will throw a finder exception and hence create will get fired.
    I understand that this is not a good coding style but then it is not 100% wrong and i need to find out as to why it is not working.
    Hope am clear in explaining my problem
    Thanks
    Shanki

  • Unique Key Violation error while updating table

    Hi All,
    I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called ActivityAttendee. ActivityAttendee has the following columns. The problem to debug is this table has
    over 23 million records. How can I catch where my query is going wrong?
    ActivityAttendeeID INT PRIMARY KEY IDENTITY(1,1)
    ,ActivityID INT NOT NULL (Foreign key to parent table Activity)
    ,AtendeeTypeCodeID INT NOT NULL
    ,ObjectID INT NOT NULL
    ,EmailAddress VARCHAR(255) NULL
    UNIQUE KEY is on ActivityID,AtendeeTypeCodeID,ObjectID,EmailAddress
    We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INT NOT NULL, intNewObjectID INT NULL)
    The problem is ActivityAttendee table might already have the new ObjectID and the unique combination.
    For example: ActivityAttendee Table have the following rows
    1,1,1,1,NULL
    2,1,1,2,NULL
    3,1,1,4,'abc'
    AND the temp table has 2,1
    So essentially when I update in this scenario, It should ignore the second row because, if I try updating that there will be a violation of key as the first record has the exact value. When I ran my query on test data it worked fine. But for 23 million records,
    its going wrong some where and I am unable to debug that. Here is my query
    UPDATE AA
    SET AA.ObjectID = TMP.NewObjectID
    FROM dbo.ActivityAttendee AA
    INNER JOIN #tmpActivityMapping TMP ON AA.ObjectID = TMP.ObjectID
    WHERE TMP.NewObjectID IS NOT NULL
    AND NOT EXISTS(SELECT 1
    FROM dbo.ActivityAttendee AA1
    WHERE AA1.ActivityID = AA.ActivityID
    AND AA1.AttendeeTypeCodeID = AA.AttendeeTypeCodeID
    AND AA1.ObjectID = TMP.NewObjectID
    AND ISNULL(AA1.EmailAddress,'') = ISNULL(AA.EmailAddress,'')

    >> I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called Activity_Attendee. <<
    Your problem is schema design. Singular table names tell us there is only one of them the set. Activities are one kind of entity; Attendees are a totally different kind of entity; Attendees are a totally different kind of entity. Where are those tables? Then
    they can have a relationship which will be a third table with REFERENCES to the other two. 
    Your table is total garbage. Think about how absurd “attendee_type_code_id” is. You have never read a single thing about data modeling. An attribute can be “attendee_type”, “attendee_code” or “attendee_id”but not that horrible mess. I have used something like
    this in one of my busk to demonstrate the wrong way to do RDBMS as a joke, but you did it for real. The postfix is called an attribute property in ISO-11179 standards. 
    You also do not know that RDBMS is not OO. We have keys and not OIDs; but bad programmers use the IDENTITY table property (NOT a column!), By definition, it cannot be a key; let me say that again, by definition. 
    >> ActivityAttendee has the following columns. The problem to debug is this table has over 23 million records [sic: rows are not records]<<
    Where did you get “UNIQUE KEY” as syntax in SQL?? What math are you doing the attendee_id? That is the only reason to make it INTEGER. I will guess that you meant attendee_type and have not taken the time to create an abbreviation encoding it.
    The term “patent/child” table is wrong! That was network databases, not RDBMS. We have referenced and referencing table. Totally different concept! 
    CREATE TABLE Attendees
    (attendee_id CHAR(10) NOT NULL PRIMARY KEY, 
     attendee_type INTEGER NOT NULL  --- bad design. 
        CHECK (attendee_type BETWEEN ?? AND ??), 
     email_address VARCHAR(255), 
    CREATE TABLE Activities
    (activity_id CHAR(10) NOT NULL PRIMARY KEY, 
    Now the relationship table. I have to make a guess about the cardinally be 1:1, 1:m or n:m. 
    CREATE TABLE Attendance_Roster
    (attendee_id CHAR(10) NOT NULL --- UNIQUE??
       REFERENCES Attendees (attendee_id), 
     activity_id Activities CHAR(10) NOT NULL ---UNIQUE?? 
      REFERENCES Activities (activity_id)
     PRIMARY KEY (attendee_id, activity_id), --- wild guess! 
    >> UNIQUE KEY is on activity_id, attendee_type_code_id_value_category, object_id, email_address <<
    Aside from the incorrect “UNIQUE KEY” syntax, think about having things like an email_address in a key. This is what we SQL people call a non-key attribute. 
    >> We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INTEGER NOT NULL, intNewObjectID INTEGER NULL) <<
    Mapping?? We do not have that concept in RDBMS. Also putting meta data prefixes like “int_” is called a “tibble” and we SQL people laugh (or cry) when we see it. 
    Then you have old proprietary Sybase UODATE .. FROM .. syntax. Google it; it is flawed and will fail. 
    Please stop programming until you have a basic understanding of RDBMS versus OO and traditional file systems. Look at my credits; when I tell you, I think I have some authority. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Null Values in a unique key in a Merge????

    We have OWB 9.2.0.2.8 and Oracle 9i
    I have a Mapping with a Source table (A), a Target table (B) and an Insert/Update Loading Type.
    I make a Match by constraint with a “unique key” in the Target table with two Fields: Field1 and Field2
    The problem is the Field2 could be NULL then If I have In TABLE A (Field1: XXX and Field2: NULL) and in TABLE B (Field1: XXX and Field2: NULL) it don’t match because Field2 has NULL value and the INSERT fails.
    I need to use a NVL function. For example:
    UPDATE
    ….
    ….
    ….
    Where nvl(A.Field2,’*’) = nvl(B.Field2,’*’)
    I could create a NVL to TABLE A (Source) with a “Expression object” but How can I create a NVL to TABLE B.
    I need to generate the nvl(B.Field2,’*’) part of the instruction nvl(A.Field2,’*’) = nvl(B.Field2,’*’).
    How can I do it???
    Thanks very much!

    Hi Claudio,
    well, I have an solution although it is neither nice nor clean...
    * Add a column Field2_notnull to Table B with not null-constraint and same type as Field2
    * Add a check-constraint to Table B like this: "nvl(Field2,'*') = Field2_notnull"
    * Create a UNIQUE KEY on Table B's Field1 and Field2_notnull and use this constraint for the MERGE-Load (INSERT/UPDATE)
    * Coming from Table A, use Field1 and nvl(Field2,'*') for the match
    As I said, neither nice nor clean, but it works, as long as you can manage to fill Field2_notnull in Table B correctly.
    Best regards
    Andreas

  • Normal Indexes created for Primary/Unique Keys in Oracle8/8i

    I remeber prior to Oracle8, when we create a Primary/Unique Key constraints, an unique index will be created by default. But I am noticing now in 8/8i when we create either Primary or Unique key, only normal/simple index is created. We are not able to override this normal index either by dropping and recreating the index alone. I believe it would be pretty much better in case of performance if we have a unique index for this columns. Can anybody help why is it changed so in 8/8i??
    Thanks,
    R. M.

    Dear Rob,
    since your answer was helpful and since it was the only one I will grant you full points on that.
    Thanks again for your input. In case other developers should look this thread up being confronted
    with the same kind of problem, here is how we solved it:
    We added an artificial primary key (a number of type NUMC 8) to the table which is supposed to
    include the structure. This key alone takes care of the uniqueness of eacht entry.
    All the others fields that we want to have available for a fast direct access, including the ones
    from the included structure, are put together in a secondary index.
    best regards
    Andreas

  • SQL Developer 1.5: Mysql unique index problem

    I experienced a problem with SQL Developer 1.5: uniqueness of multiple fields indexes seems to be lost. On single field indexes it works properly.
    As you can see generated code lacks the "UNIQUE" keyword
    MySQL DDL:
    CREATE TABLE `my_table` (
    `aaa` CHAR(20) COLLATE latin1_swedish_ci NOT NULL DEFAULT '%',
    `bbb` CHAR(4) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
    `ccc` CHAR(4) COLLATE latin1_swedish_ci NOT NULL DEFAULT '%',
    `ddd` CHAR(4) COLLATE latin1_swedish_ci NOT NULL DEFAULT '%',
    `eee` CHAR(4) COLLATE latin1_swedish_ci NOT NULL DEFAULT '%',
    `fff` CHAR(30) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
    `ggg` CHAR(30) COLLATE latin1_swedish_ci DEFAULT NULL,
    UNIQUE KEY `All` (`aaa`, `bbb`, `ccc`, `ddd`, `eee`, `fff`, `ggg`),
    KEY `key_bbb` (`bbb`),
    KEY `key_ccc` (`ccc`)
    )ENGINE=MyISAM
    ROW_FORMAT=FIXED CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';
    Generated code:
    CREATE TABLE my_table \[...\]
    CREATE INDEX All_ ON my_table
    aaa,
    bbb,
    ccc,
    ddd,
    eee,
    fff,
    ggg
    \[...\]

    That looks strange. I created the following three tables in mySQL:
    CREATE TABLE `my_table_a` (
    `aaa` CHAR(20) ,
    `bbb` CHAR(4) ,
    UNIQUE KEY `All` (`aaa`, `bbb`),
    KEY `key_aaa` (`aaa`),
    KEY `key_bbb` (`bbb`)
    CREATE TABLE `my_table_b` (
    `aaa` CHAR(20) ,
    `bbb` CHAR(4) ,
    UNIQUE KEY `All` (`aaa`, `bbb`),
    UNIQUE KEY `key_aaa` (`aaa`),
    KEY `key_bbb` (`bbb`)
    CREATE TABLE `my_table_c` (
    `aaa` CHAR(20) ,
    `bbb` CHAR(4) ,
    UNIQUE KEY `All` (`aaa`, `bbb`),
    KEY `key_aaa` (`aaa`),
    UNIQUE KEY `key_bbb` (`bbb`)
    The wrong result can already be seen in the captured model.
    Result for my_table_a:
    All: NON_UNIQUE
    key_aaa: NON_UNIQUE
    key_bbb: NON_UNIQUE
    Result for my_table_b:
    All: UNIQUE
    key_aaa: UNIQUE
    key_bbb: NON_UNIQUE
    Result for my_table_c:
    All: NON_UNIQUE
    key_aaa: NON_UNIQUE
    key_bbb: UNIQUE
    So there is at least one case where an index with two segments is remaining UNIQUE. But as soon as the index has three segments, the UNIQUE is lost.
    I'll check whether this is a known bug, and if not, I'll create a new bug.
    Regards,
    Wolfgang

  • How to use Unique key constraint in EJB

    Hi All,
    I am using an entity bean to create my table in MySQL4.1.13
    I have a table called user which has userid,username,password as its columns.
    The userid is a primary key over here.
    But I want the user name to be unique.
    I.e if a user with the name 'Adrian' is present in the database then another user with this user name should not be created.
    I have been told that you can configure a unique key in jbosscmp-jdbc.xml using insert-after-ejb-post-create.
    But i dont know how to use it.
    Can anyone give me a sample code for using this.
    Any help would be appreciated.
    Thanks
    P2

    Please explain your problem better. Really can't figure what you are trying to do.....
    choosing which sql statement to use at runtime
    or creating dynamic sql statement at runtime
    which??
    Regards

  • Groovy Expression get Values of Unique Key

    Hi all,
    I am trying to create a custom error message for a unique key validation. With other error messages that just evaluate one field I have been able to do things like:
    Value {0} already exists
    With the token for 0 being newValue. When I am validating a unique key when I pull newValue it gives me one of the fields it validates on, is there another expression to get all the values?
    Thanks!
    JDEV 11.1.2.2.0

    hi,
    you can directly use attrName to get the particular attrValue..
    like instead of using newValue using attr FirstName.
    if you want to customize the error message more then you can create entityImpl class and create a method that will return the custom error message i.e you have a method like getErrorMessage() then you can access it like
    adf.source.getErrorMessage().. but i think the first one will solve your problem....
    Regards,

  • Duplicate Unique Key declaration in DDL export

    Using v1.1.2.25 of the product, I performed a DDL export of selected tables and noted in the resulting file that my two Unique Keys were duplicated (created twice). This caused no real problem except a couple of error message that will confuse customers, so I have to manually extract the second declarations. Did I miss something, or is this a bug?

    Define key_element as a key (or unique)! Check the schema specification at http://www.w3.org/TR/xmlschema-1/#cIdentity-constraint_Definitions. If you're up to a challenge translate the specification from W3-ese to a meaningfult language, or take a short cut and read the example in section 3.11.2.
    Support for keys in validation is sometimes spotty, but it's pretty easy to code up your own checks if needed.

  • Unique key violation i.e. primary key violation in JSF page

    Hi, I am using Jdeveloper 11.1.1.5.0 and working with adf fusion web application. I have created entity object and view object. In view object I have primary key and I have set it's type to DB sequence. THe problem is though the attribute is DB sequence. IN JSF page it show unique key violation i.e. primary key violation. Please help me

    So, do you have a trigger in the database that updates the value of the primary key? Or do you assign the value in some other way?
    You can check [url http://download.oracle.com/docs/cd/E16162_01/web.1112/e16182/toc.htm]the docs for information about the ways it can be done.

  • Variable {column} in unique key template

    In unique constraint, the variable column not works when i do engineering to physical model.
    For example, my template is {table}_{column}_UK, after engineering my unique key stay table__uk, when I expect table_column_uk
    Version 4.0.3.853

    Hi,
    thanks for reporting the problem, I logged a bug.
    It appears columns are not taken into account for UK name during engineering. You always can apply templates on the whole relational model using "Apply naming standards to Keys and Constraints" in context menu for relational model in the browser.
    Philip

  • Need to Create Unique key basis on Internal Refrence code in Oracle Product Hub

    Hi Friends
    We are in to new development of product catalog in Oracle Product Hub , As per the client requirmnent we have to
    create  a primary key attribute basis on the Internal refrence code for product and promotion
    can any one please take interest and help for us to resolve this iussue.
    Praveen Singh Rathore

    Hi,
    Thanks,
    There are 3 columns involved with that table . Out of whihc one is a Primary Key (string) , The other column (Number) has a unique key constraint defined on it and the last column stores a value corresponding to the 2nd column.
    The reason for me to do a create in the Finder exception is as follows.
    I Loop through the Data present in JTable. As given in the example let us assume that there are 2 rows in the JTable. Out of whihc the First row needs an updation and the second row , which is a new row needs to be created. So During the First iteration of the loop, The findermethod does not throw any exception (Because it is a modfied row) and hence the update gets fired successfully. During the second iteration , since it is a new row the findermethod will throw a finder exception and hence create will get fired.
    I understand that this is not a good coding style but then it is not 100% wrong and i need to find out as to why it is not working.
    Hope am clear in explaining my problem
    Thanks
    Shanki

Maybe you are looking for

  • Question re Command Object to populate parameter drop-down

    I have a report that uses a SQL Server stored procedure as the data source. The first parameter they enter is their company number (we have numerous clients using Lawson and access Crystal through LBI). The next parameter is the account number. I hav

  • Files and Streams java -- Sequential access file-- Plz help me

    I am able to add records in sequential file and then also I am able to display each record sequentially. But after closing the file if I open the file for adding records, the newly added records are not being displayed while clicking the "next" butto

  • Need an iMovie 09 Recommendation

    On my computer, iMovie 09 is running over 100% CPU causing it to freeze up or not responding. I have the basic 2 gigs of RAM and have about 800MB of memory free. What could I do to fix this problem? I have a project in iMovie that is a little over an

  • Anchoring Linked Frames or ICML Files???

    Is there anyway to anchor linked frames or ICML files in InDesign? I would like to re-purpose some content from other files and anchor the text into the text frame so the content flows around it. I notice when I try to cut-n-paste to anchor, the link

  • Data Refresh

    Hello Gurus We have a query reg the data refresh....recently we have made the the Quality CRM and R/3 data refresh, i want to know wht all the things we need to be  consider for post data refresh i mean in terms of middleware........ as per my knowle