Wednesday, 6 December 2023

java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected - got CLOB

Case:
Case 1:
i had this Error when executing a VO that have a CLOB column

Case 2:
i had another case where there was a CLOB column in the database and it was set in the Entity as oracle.jbo.domain.ClobDomain

i retrieved this column through a ROV and set it in a PageFlowScope Object and showed that PageFlowScope Object on the screen



Problem:

For Case 1:
i was getting ORA-00932 error when executing a Query that have a CLOB column

For Case 2:
the problem was that after running or deploying the application on the server, the CLOB field was showing correctly right after running or deployment, but after 2 or 3 hours, the same field showing the CLOB didnot show any data, but this case did not throw any exceptions in the log.


Solution:

the attribute in the entity/view should be defined this way:

<Attribute
Name="YOUR_ATTRIBUTE_NAME_IN_VO"
IsQueriable="false"
ColumnName="YOUR_COLUMN_NAME_IN_TABLE"
SQLType="CLOB"
Type="java.lang.String"
ColumnType="CLOB"
TableName="YOUR_TABLE_NAME"/>



and in the RowImpl the attribute should be a String


it should also be noted that if you know that your CLOB will hold characters more than 4000, then you will have to split your CLOB into parts to be able to show all data inside it as shown below;

we will use the DBMS_LOB.SUBSTR which is used for taking a part of the CLOB to avoid having more than 4000 characters.

dbms_lob.substr( clob_column, for_how_many_bytes, from_which_byte );

we alos use DBMS_LOB.GETLENGTH to get the length of the CLOB to make sure we get the data correct.

for more info about these functions check these links 

DBMS_LOB Oracle Doc


DBMS_LOB.SUBSTR (yout_column_name, 4000, 1) AS yout_column_name_pt1 

      ,CASE WHEN dbms_lob.getlength (yout_column_name) > 4000  THEN DBMS_LOB.SUBSTR (yout_column_name, 4000, 4001) END AS yout_column_name_pt2 

       ,CASE WHEN dbms_lob.getlength (yout_column_name) > 8000  THEN DBMS_LOB.SUBSTR (yout_column_name, 4000, 8001) END AS yout_column_name_pt3 

       ,CASE WHEN dbms_lob.getlength (yout_column_name) > 12000 THEN DBMS_LOB.SUBSTR (yout_column_name, 4000, 12001) END AS yout_column_name_pt4    


Sunday, 21 August 2016

Primary Key importance

Many JBO Exceptions was raised with me due to having a view object without having a primary key in it, so make sure any view object you create have a primary key.

problem with the format of the Number or BigDecimal in ADF

 if you made a format on a Number or BigDeciaml in the VO like ###,###,###.00  and it doesnot work, then put the property groupingUsed="true" on the af:convertNumber of the input text

Sunday, 27 December 2015

JBO-25013: Too many objects match the primary key null

JBO-25013: Too many objects match the primary key null

i Encountered This Error while i was trying to change an attribute in the selected row (selected by the user on the screen), and there was an Alternative Key on that iterator view/entity, setting/changing that attribute i wanted to change would make that Alternative Key repeat, which triggered that error, after removing that Alternative Key, the error no longer appeared and there was no error.
so just remove the Alternative Key and try again, it should work smoothly.

source: i got it from this topic ( the last answer by the person who asked this question )

Monday, 13 April 2015

How to generate a random password in Java ?

Today i was looking for a way to make a random generated password, and i made some search and the best thing i found was the method below. 




if you want to generate a random password (for forgot password scenario, and email this random password to the user), use the following class RandomStringUtils  


this is the code to generate the password, 

RandomStringUtils.randomAlphanumeric(20).toUpperCase();
20 = number of random chars in the generated password, 
you can change this number based on how many chars you want 
in your random generated password.
but you have to add the library that contains the RandomStringUtils class to the project you are working on to be able to import it, the libraries that contain this class are called (JRF Client, JAX-RS Jersey Jackson (Bundled))

Source:

http://stackoverflow.com/questions/41107/how-to-generate-a-random-alpha-numeric-string

Thursday, 26 March 2015

How to disable RichInputText in an ADF page programmatically

Hi, it is Mostafa Amine here, this is my First blog Ever, i always wanted to blog but i never had or made time for that, so here i am writing my First Blog entry Ever, hope it will be Helpful to Everyone who reads it or stumbles upon it :)






so a few days ago i wanted to disable a RichInputText and a RichCommandToolbarButton programmatically from a Managed bean, all i could find on the internet was CSS and JQuery solutions, so here is a solution for those who donot want to go through CSS and JQuery or who are using page Fragments (.jsff) like me




to disable components like (RichInputText , RichCommandToolbarButton  or RichSelectBooleanCheckbox), you can bind that component that you want to disable programmatically and then make a new  (RichInputText , RichCommandToolbarButton  or RichSelectBooleanCheckbox) based on your scenario, then set the property disabled  of this component to True and then assign your component (that you want to disable) to that newly created disabled component, below is the code of how to do so



        RichInputText newInputText= new RichInputText();

        newInputText.setDisabled(true);
       set<YourInputTextName>(newInputText);


      RichSelectBooleanCheckbox newChckBox = new RichSelectBooleanCheckbox();

      newChckBox .setDisabled(true);
     set<YourChckBoxName>(newChckBox );




     RichCommandToolbarButton newCmdBttn= new   RichCommandToolbarButton();

     newCmdBttn.setDisabled(true);
     set<YourCmdBttnName>(newCmdBttn);



you might ask, why would not you just set the binding's disabled property directly instead of making a new UI component n setting its disabled property, i found that this method doesnot always work, specially if you want to disable/enable your component in the constructor if your bean, you have to use this method.