Retrieve DB Column length from hibernate?

To retrieve the Db column length from hibernate. I have used:

Property property = (Property)persistentClass.getProperty(propertyName);

                 Column col = (Column)property.getColumnIterator().next();

                 int length = col.getLength();


                System.out.print("\t  Column length :::");

The table structure I have is :

TYPE_ID          NUMBER                            
TYPE_NAME        VARCHAR2(200)                    
CREATION_DATE    DATE                             
CREATED_BY       VARCHAR2(200)  Y                
LAST_UPDATE_DATE DATE           Y                 
LAST_UPDATED_BY  VARCHAR2(200)  Y                                    
DISPLAY_NAME     VARCHAR2(200)  Y                                                 
ENABLED          VARCHAR2(1)    Y                    

the results I got from using hibernate is:

CREATED_BY        Column length :::255  STRING
CREATION_DATE     Column length :::255  TIMESTAMP
DESCRIPTION       Column length :::255  STRING
DISPLAY_NAME      Column length :::200  STRING
ENABLED           Column length :::255  STRING
LAST_UPDATED_BY   Column length :::255  STRING
LAST_UPDATE_DATE  Column length :::255  TIMESTAMP
TYPE_NAME         Column length :::200  STRING

Please advice..


Generally, Hibernate does not care how the underlying database looks like, as long as everything works properly on the jdbc level.

The safest way to get the information you need is to query the Oracle dictionary directly:

select COLUMN_NAME, DATA_LENGTH from USER_TAB_COLS where table_name = '<TABLE>';

You can execute this as native query, or you can map an (probably @Immutable) entity to the USER_TAB_COLS table to utilize JPQL/HQL and EntityManager/Session API.

Need Your Help

unlockFocus called too many times

objective-c macos nspanel

I click on a NSButton (openPanel) which is located on the main window of my OS X app to show a NSPanel (myPanel) using the following method:

Bootstrap 3.1.1 - What is the .map extension file used for?

twitter-bootstrap twitter-bootstrap-3

I need to upgrade an application I'm working on with the latest Bootstrap version but I'm struggling to figure out what an addition of is for?