I want to use the findByKey() method to check if a specific value is already in the database. I use the following code snippet to do this:
String Nr = "SearchStringPart1";
AttributeListImpl al = new AttributeListImpl();
al.setAttribute("UniqueKeyPart1",new Number(1));
al.setAttribute("UniqueKeyPart2",Nr);
Key myKey = myViewObject.createKey(al);
Row[] rows = myViewObject.findByKey(myKey,2);
If I run this code snippet "rows[]" will be empty, even if the queried data
does exist.
UniqueKeyPart1 and UniqueKeyPart2 form together a unique key in the database and they are marked as "Keys" in the Attribute Settings of "myViewObject". However, they are no primary keys.
If I change the code snippet to query the primary key I
do get some results:
AttributeListImpl al = new AttributeListImpl();
al.setAttribute("PrimaryKey",new Number(13));
Key myKey = myViewObject.createKey(al);
Row[] rows = myViewObject.findByKey(myKey,2);
Question:
---------
Is it possible, that "findByKey" can only find primary keys? This is not documented in the documentation.