Developer Notes 001

This article selects a few developer notes collected during the software development, which were unfortunately not enough for a self-standing article.

Developer notes will be an irregular series of articles where I will briefly go through some of my notes to make notes for posterity. The notes themself can be pretty long, yet their length is not enough for writing a meaningful article.

Let’s take a look at a list of content:

Oracle Error: Value Larger Than Specified Precision Allowed For This Column

I was getting errors on inserting data into the Oracle database “ORA-01438: value larger than specified precision allowed for this column.”

The reason why I was getting an error was a too big number. When I looked over UI to database column definition, I saw something like this NUMBER(15,2).

Official Oracle documentation, as for Oracle database v21, depicts NUMBER datatype defined as NUMBER (precision,scale).

NUMBER datatype notation can be rather rewritten to NUMBER (size,precision)) where the first number depicts the total size of the digits in a number, and the second means the decimal point scale.

In other words, for example, for NUMBER(2,2), we can place the column number consisting of 2 digits, both of which will be decimals. i.e. 0.15, 0.45 etc. But if we would like to have a bigger number in the column, we need to upgrade the size of the column reserved for the whole number – NUMBER(5,2) will get us five digits, of which 2 are decimals. i.e 125.40, 18.00.

Switch on String with Enum Name in Java 8

Here is an example of how to use Enum values as strings in a switch case. You can only use the strings which are known at compile time. The compiler cannot determine the result of expression. However, in Java Enum case VALUE1, VALUE2 are static.

String name = ...
switch(CustomEnum.valueOf(name)) {
   case VALUE1:
        ...
        break;
   case VALUE2:
        ...
        break;
    ...
}

Lombok’s serialization error for Jackson

When I created a new aggregated DTO class on my REST output, I got the following error:

Type definition error: [simple type, class CUSTOM_DTO_CLASS_NAME]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class CUSTOM_DTO_CLASS_NAME and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: CUSTOM_DTO_CLASS_NAME[\"aggregation-class-property\"]->java.util.ArrayList[0])

I am sure this error will be thrown quiet often as the solution on it is very simple. All I was missing on my Custom DTO class was Lombok’s @Getters annotation for serialization. So fix consisted on adding missing @Getters annotation on the top of my custom class for Lombok generating getter methods at compile time.

Interpunct

I was editing my resume this month and wanted to create a nice date range in positions I held in the past. I got this from my LinkedIn profile, where LinkedIn use dates in the form as Jan 2020 – Feb 2020 · 2 mos. But I could not figure out where to take the dot sign as it was an image. However, the character for such sign as little black dot · really exists and its name is Interpunct, or middle dot. So every time you would like to create a nice division of text with the help of ·, think about the Interpunct.

How To Do curl in Postman

Is there a way hot to make a curl command in Postman? What if we would like to import the curl command easily into Postman and make a Postman GUI request from it.
Is it even possible to easily translate all the curl command parameters into the Postman request?

Surely it is. Postman request are eventually nothing else than more fancy curl requests and Postman supports the curl import feature. Importing curl is very simple. Here is simple list of steps which will lead you to success:

  1. Open Postman.
  2. Go to navigation menu, click File and Import option
  3. In Import window select the raw text tab.
  4. Paste the raw text e.g. curl --location --request GET "https://www.google.com/", then click continue.
  5. Check the name, format and import as.
  6. If everything is correct, click Import button.

Following the steps will automatically import the curl command into the Postman on the new tab.

This entry was posted in Tips & tricks and tagged , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.