IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes Field Size Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Field Size" Watch "Field Size" New topic
Author

Field Size

Patrick McDonogh
Ranch Hand

Joined: Oct 13, 2005
Posts: 89
Hi there all,

I am storing a large ammount of formatted data i.e. it has html tags in it, etc. In my POJO which is mapped to the database i am storing this information in a java.lang.String. I have this property mapped to the database column using xml i.e. <property name="theProperty" column="column_name"/>

When i persist the object it throws an exception saying that the data in the field is too large for the column.
I have been looking in the hibernate manual for something about this, i thought i may need to specify a different type and length but couldnt find out how to do it.
Does anyone know where i am going wrong.

I am using MySql as the database and know that mysql has datatypes longblob and longtext. How do i tell the mapping file to use these types and what should the value in the pojo be i.e. should it still be java.lang.String?

Therefore, i guess i am asking how to model large amounts of data and how to set explicit database datatypes using the mapping files? If you have a solution and know where this info is in the online hibernate manual could you please let me know where?

Thanks for your help and have a great day.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

From the Hibernate mapping point of view your property is a String. See this.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
karthick swami
Greenhorn

Joined: May 14, 2007
Posts: 4
Hi,

This exception occurs when the Database field size mentioned is less than the size of the field i.e to be stored.
The size has to be changed in the DB.Nothing to do with the mapping file.

Regards,
Karthick Swaminathan
 
IntelliJ Java IDE
 
subject: Field Size
 
Threads others viewed
Need help on reading CLOB column
Insert via Hibernate and Stored Procs
hibernate many to one question
Hbm2JavaTask won't generate composite user types correctly
How to read/write Blob images using Hibernate
developer file tools