0

I have a web application that works on both Oracle and MySQL Databases, my problem is that I want to create a column in the database that has a LONGTEXT type in MySQL and CLOB in Oracle, how can I achieve that using Hibernate? Here is my code:

@Column(name = "BigText" , nullable = false)
public String getBigText() {
    return bigText;
}

I tried using: columnDefinition="LONGTEXT", it is working under MySQL but not Oracle. What else can I do?

Shahe
  • 964
  • 2
  • 13
  • 34

1 Answers1

0

see the below link

defference between oracle and mysql datatype

if(databasename.equals("oracle"){ use here entity for oracle datatype used }else if(databasename.equals("mysql"){ use here entity for mysqldatatype used }

suresh manda
  • 659
  • 1
  • 8
  • 25
  • Have you even read my question? this should not be an answer BTW. I know the differences between the two databases and data types (I have been working on both databases for 2 years.. Dah!!) – Shahe Nov 12 '14 at 07:01
  • you get the database name and write the if condition for oracle and mysql use different entity based on database – suresh manda Nov 12 '14 at 07:03
  • see the answer...understand – suresh manda Nov 12 '14 at 07:08
  • I can't create different entities for my table, I have to use ONE entity. – Shahe Nov 12 '14 at 07:15
  • i phase this type of problem with three databases.so i create three entities.and used in dao with database name – suresh manda Nov 12 '14 at 07:23
  • Here is the thing, my application creates the database tables on startup (hibernate does that). So I need to add the annotation NOT create other entities for every database. – Shahe Nov 12 '14 at 07:25