-
Apr 6th, 2012, 09:23 PM
#1
Reverse engineer MySql table with text field
Hello,
I did a reverse enineering of my MySql schema.
I typed in a:
database reverse engineer --package ~.domain --schema PUBLIC
The command went fine.
But then when running the integration tests I got:
Caused by: org.hibernate.HibernateException: Wrong column type in db_integration.admin for column profile. Found: text, expected: varchar(255)
How come Roo doesn't accept the text field ?
Here is the table structure:
mysql> desc admin;
+------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| version | int(10) unsigned | NO | | NULL | |
| firstname | varchar(255) | NO | | NULL | |
| lastname | varchar(255) | NO | | NULL | |
| login | varchar(50) | NO | UNI | NULL | |
| password | varchar(100) | NO | | NULL | |
| password_salt | varchar(50) | YES | | NULL | |
| super_admin | tinyint(1) | NO | | NULL | |
| preference_admin | tinyint(1) | NO | | NULL | |
| address | varchar(255) | YES | | NULL | |
| zip_code | varchar(10) | YES | | NULL | |
| city | varchar(255) | YES | | NULL | |
| country | varchar(255) | YES | | NULL | |
| email | varchar(255) | YES | | NULL | |
| profile | text | YES | | NULL | |
+------------------+------------------+------+-----+---------+----------------+
15 rows in set (0.00 sec)
Kind Regards,
Stephane
Stephane
-
Apr 6th, 2012, 09:42 PM
#2
I'm using Roo 1.2.1.RELEASE [rev 6eae723]
Stephane
-
Apr 6th, 2012, 09:51 PM
#3
I can see in the dbre.xml file the following:
<column name="profile" primaryKey="false" required="false" scale="0" size="65535" type="-1,TEXT"/>
It seems the reverse ingineering was fine, as the field was not seen as a VARCHAR, like for example:
<column name="email" primaryKey="false" required="false" scale="0" size="255" type="12,VARCHAR"/>
So, how come the integration test desn't see it that way too ?
Stephane
-
Apr 6th, 2012, 09:58 PM
#4
The generated Admin domain class:
@RooJavaBean
@RooToString
@RooJpaActiveRecord(table = "admin")
@RooDbManaged(automaticallyDelete = true)
public class Admin {
}
Stephane
-
Apr 6th, 2012, 10:01 PM
#5
The file Admin_Roo_DbManaged.aj contains:
@Column(name = "profile")
private String Admin.profile;
So I manually edited this annotation to have it like:
@Column(name = "profile", columnDefinition="TEXT")
And the issue was solved.
So now I have to fo the same thing for all the text fields :-)
Last edited by stephaneeybert; Apr 6th, 2012 at 10:10 PM.
Stephane
-
Apr 10th, 2012, 08:09 AM
#6
It is possible to add "--includeNonPortableAttributes" to reverse engineering command, so it will create all your classes correctly. (BLOB type has the same problem.)
-
Apr 10th, 2012, 05:56 PM
#7
The issue is with Hibernate and not DBRE. You have reverse engineered but are now experiencing a problem going "forward" to the DB with the ORM. louisnerys suggestion of using --includeNonPortableAttributes should help.
-
Apr 11th, 2012, 03:00 AM
#8
Okay, will try that, thanks.
Stephane
-
Apr 13th, 2012, 02:13 PM
#9
The --includeNonPortableAttributes attribute produced the desired result of having the columnDefinition = "TEXT" for the column annotation.
Stephane
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules