Business Logic / Datatypes | org.jaffa.datatypes |
We have come up with a concise set of datatypes as listed in the table below.
The table also lists the corresponding SQL Datatype and the Java class for a logical datatype
You may not agree these, but when building a business application, i greatly simplyfies the process, and
the reason Jaffa is open source is so you can extend this list if you want
Jaffa Prefered Data Types
Jaffa Logical Datatype |
SQL Datatype |
Java class |
org.jaffa.datatypes.Defaults.BOOLEAN |
java.sql.Types.VARCHAR |
java.lang.Boolean |
org.jaffa.datatypes.Defaults.STRING |
java.sql.Types.VARCHAR |
java.lang.String |
org.jaffa.datatypes.Defaults.INTEGER |
java.sql.Types.BIGINT |
java.lang.Long |
org.jaffa.datatypes.Defaults.DECIMAL |
java.sql.Types.DOUBLE |
java.lang.Double |
org.jaffa.datatypes.Defaults.DATEONLY |
java.sql.Types.DATE |
Org.jaffa.datatypes.DateOnly |
org.jaffa.datatypes.Defaults.DATETIME |
java.sql.Types.TIMESTAMP |
Org.jaffa.datatypes.DateTime |
org.jaffa.datatypes.Defaults.CURRENCY |
java.sql.Types.DOUBLE |
Org.jaffa.datatypes.Currency |
org.jaffa.datatypes.Defaults.RAW |
java.sql.Types.VARBINARY |
byte[] |
org.jaffa.datatypes.Defaults.LONG_STRING |
java.sql.Types.LONGVARCHAR |
java.lang.String |
org.jaffa.datatypes.Defaults.LONG_RAW |
java.sql.Types.LONGVARBINARY |
byte[] |
org.jaffa.datatypes.Defaults.CLOB |
java.sql.Types.CLOB |
java.lang.String |
org.jaffa.datatypes.Defaults.BLOB |
java.sql.Types.BLOB |
byte[] |
Notes:
- It is recommended to use instances of the listed Java classes inside Data Transfer Objects (DTOs) for
transferring data between the different layers of the architecture
- The Jaffa Logical Datatypes are specified in the mapping files used by the Persistence Engine, which
then uses the appropriate SQL datatype to load/store instances of the corresponding Java class
- We’ve created a couple of custom classes for wrapping date fields, adding the much needed arithmetic
and logical functionality, without sacrificing the immutability of a datatype
- The Boolean datatype is assumed to be a CHAR(1) in the database having the values T/F. This will be
enhanced in a future release to support the BIT field and Y/N values
- The class org.jaffa.datatypes.Defaults has helper methods to get the Java class for a Jaffa Logical
Datatype and vice versa
- The class org.jaffa.persistence.engines.jdbcengine.querygenerator.TypeDefs has a helper method to
return the SQL Datatype for a given Jaffa Logical Datatype
|