1

As mentioned I need to set the size of the column in Hibernate , default for String it takes varchar(255) While creating the table,

I need to make it as varchar(8000) on the time of table creation.

I've already found couple of answers using 'Annotations'- like

  • @Column(length = 255)
  • @Lob

But is there any other way to do the same without using 'Annotations'

Thank You.

PRATHAP S
  • 675
  • 2
  • 8
  • 26
  • I don't think if there is any way. But you can do By JavaScript on Page and On Server Side Controller Class. In Struts its Action Class and in JSF its Managed Bean. You shouldn't do validation at this layer. – MRX Jun 25 '14 at 09:45
  • @Kshitij Yes I've done in that way right now. And that controller class should be called only once after creating the table. – PRATHAP S Jun 25 '14 at 09:51
  • Oh. Sorry. i did not read that. I read only last four lines. – MRX Jun 25 '14 at 09:54
  • @Kshitij so the solution is? – PRATHAP S Jun 25 '14 at 09:59
  • Not Sure but Java Reflection could help. Your requirement is rare. – MRX Jun 25 '14 at 12:40
  • @Kshitij Since annotations does work in our IDE I wanted the solution for this. Hence only way to do this is from the back-end, every-time after table creation. Thank you. – PRATHAP S Jun 26 '14 at 04:45
  • My Advise on this that for Table Creation you should Call Web Service and that Web Service should be capable of hendling Annotation (Means you can Put Whole JPA Layer there). When ever you need to creation Database you should call web service. Also you can call it when application deployment time. – MRX Jun 26 '14 at 06:52
  • @Kshitij Yes Idea is good!, But we do same thing in a different way that's all. Thanks again. – PRATHAP S Jun 26 '14 at 07:23

1 Answers1

3

When you say 'not using annotations', I assume you are using hibernate xml mapping files? I believe in the xml mapping files, you can map a column with a length, something like:

<property name="mycolumn" column="mycolumn" type="java.lang.String" length="8000" />
Matt
  • 3,303
  • 5
  • 31
  • 53