This might be a very basic issues but I tried many things but getting issues with all. Daddies please ignore.
CASE 1:
When I mention my mappings in hibernate.cfg.xml as below:
<mapping class="com.tm.midservice.db.dto.User"/>
<mapping class="com.tm.midservice.db.dto.Company"/>
I get the following errors.
INFO - org.hibernate.tool.hbm2ddl.TableMetadata - table found: demodb.company
INFO - org.hibernate.tool.hbm2ddl.TableMetadata - columns: [analytics_feature_enabled, source_domain, currency, id, updated_at, source, token, name, domain, created_at, active, mid]
SessionFactory initial creation error.org.hibernate.HibernateException: Wrong column type: active, expected: bit`
The column I have described in my DTO is as :
@Column(name = "active")
private boolean active;
(EDIT 1)
Tried the below thing, but did not work:
@Type(type="true_false")
@Column(name="active", columnDefinition = "TINYINT(1) DEFAULT 0")
private boolean active;
gives exception as:
SessionFactory initial creation error.org.hibernate.HibernateException: Wrong column type: active, expected: TINYINT(1) DEFAULT 0
(EDIT 2)
Found something at: "Found: bit, expected: boolean" after Hibernate 4 upgrade
@Column(name="active", columnDefinition = "BIT", length = 1)
private boolean active;
gives exception as:
SessionFactory initial creation error.org.hibernate.HibernateException: Wrong column type: active, expected: BIT
(EDIT 3)
Tried something as:
public class Mysql5BitBooleanDialect extends MySQL5Dialect {
public Mysql5BitBooleanDialect() {
super();
registerColumnType( Types.BOOLEAN, "bit" );
}
}
This class does get invoked, but exception does not go.
CASE 2 :
When I do not give the mapping in cfg file and try to run my application, the sessionFactory initializes and all but when I try to do any database operations I get error as :
hibernate mapping exception unknown entity
Ideally I should not be giving any mapping definitions as the DTO has got the annotations for that [@Entity & @Table (name = "User")]
.
How do I configure things properly? Any thing I am missing here? I am so stuck.