Data Types

One Star

Data Types

What's the difference between an Int and Integer in Talend Open Studio. Sometimes it shows one or the other and because of that I seem to get a NullPointerException. Can anyone explain what causes talend to use one over the other.
Thanks
One Star

Re: Data Types

Hi
It seems we have to talk about Java. Smiley Wink
An int is a primitive. It is not an Object. An int is a high performance, streamlined beast for calculating numbers.
An Integer, is a Object that contains a single int field. An Integer is much bulkier than an int. It is sort like a Fedex box to contain the int. Integers are immutable.
Always they will be transfered automatically by JVM.
In TOS, they are the same as Java.
So i don't think they will cause a NullPointerException.
Best regards!
Pedro
Seven Stars

Re: Data Types

To add to that, since an "int" is a primitve and not an Object, it does not inherit java.lang.object methods like toSting() or equals() (Lets not get into autoboxing/unboxing) and and cannot be null since null is not a valid integer. This is why when a column in "not nullable" it is an int but when changed to allow nulls becomes an Integer, because it can then be tested against null like 'row1.myInteger == null ? 0 : row1.myInteger'
One Star

Re: Data Types

Ok, so we understand the different between Java's int vs integer. However, the problem is in Talend, not java.
We can't figure out why sometimes Talend uses an "int" (the primitive type) for an int field, and sometimes it has used an "integer". What we want is an "integer" object representation, since it *is* acceptable for the field to have null values. Right now, we have a tmap in which the "left" part of the tmap is using primitive ints; and the right hand is using "integer", and since we have null values in our data, we eventually get "NullPointerExceptions" etc. How can we make all of the Talend int fields into Integer fields?
One Star

Re: Data Types

Ok, so we understand the different between Java's int vs integer. However, the problem is in Talend, not java.
We can't figure out why sometimes Talend uses an "int" (the primitive type) for an int field, and sometimes it has used an "integer". What we want is an "integer" object representation, since it *is* acceptable for the field to have null values. Right now, we have a tmap in which the "left" part of the tmap is using primitive ints; and the right hand is using "integer", and since we have null values in our data, we eventually get "NullPointerExceptions" etc. How can we make all of the Talend int fields into Integer fields?
One Star

Re: Data Types

Hi
When you check 'Nullable' of this column in your schema, you will change int type into Integer.
Best regards!
Pedro

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads