Re: problem mapping boolean mysql

199 views
Skip to first unread message

Bogdan Tanase

unread,
Jun 27, 2012, 5:06:01 PM6/27/12
to mybati...@googlegroups.com
Not sure what your problem is, since you forgot to post the actual problem description :)

But I've used boolean mapping without any issues with MyBatis+ MySql. Try to change field types for actionRead, actionWrite, etc from "int" to "boolean". 

On Wed, Jun 27, 2012 at 11:08 PM, juan miguel martín <martin.j...@gmail.com> wrote:
Hello, i have a problem with the mapping boolean column in my code:

this is my table mysql :

create table user_permission (
id bigint (20) unsigned  not null auto_increment,
resource_id bigint(20) unsigned  not null,
user_id bigint(20) unsigned  not null,
action_read TINYINT(1),
action_write TINYINT(1),
action_delete TINYINT(1),
action_edit TINYINT(1),
version int(11) NOT NULL,
primary key (id)
);

this is my java class:

public class UserPermissionImpl extends ObjectImpl implements
UserPermission {

private static final long serialVersionUID = 1L;
private long resourceId;
private long userId;
private int actionRead;
private int actionWrite;
private int actionDelete;
private int actionEdit;

@Override
public Integer getObjectType() {
return ThalamusTypes.PERMISSION_GROUP;
}

@Override
public long getResourceId() {

return resourceId;
}

@Override
public void setResourceId(long resourceId) {
this.resourceId = resourceId;

}

@Override
public void setActionRead(int actionRead) {
this.actionRead = actionRead;
}

@Override
public void setActionWrite(int actionWrite) {
this.actionWrite = actionWrite;

}

@Override
public void setActionDelete(int actionDelete) {
this.actionDelete = actionDelete;

}

@Override
public void setActionEdit(int actionEdit) {
this.actionEdit = actionEdit;

}

@Override
public int getActionRead() {
return actionRead;
}

@Override
public int getActionWrite() {
return actionWrite;
}

@Override
public int getActionDelete() {
return actionDelete;
}

@Override
public int getActionEdit() {
return actionEdit;
}

@Override
public long getUserId() {
return userId;
}

@Override
public void setUserId(long userId) {
this.userId = userId;
 }

}

public abstract class  ObjectImpl  {

private static final long serialVersionUID = 1L;

@Identity("id")
private Long id;
@Override
public Long getID() {
return id;
}

public void setId(Long id) {
this.id = id;
}


}


juan miguel martín

unread,
Jul 3, 2012, 8:44:39 PM7/3/12
to mybati...@googlegroups.com
Thanks Bogdan!!! , yes when i was writting the post i pressed some shortcut that send it... the problem was not the boolean.. my problem was the mapping but i solved it!
....my column's tables was like  LAST_NAME ...with the under_score and  I have to set the configuration :



<settings>
  <setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>

2012/6/27 Bogdan Tanase <bfta...@gmail.com>

Bogdan Tanase

unread,
Jul 4, 2012, 1:51:15 AM7/4/12
to mybati...@googlegroups.com
I hear what you're saying :)

Tip - in case you don't already know: If you use gmail to post to this list, there's the awesome "Undo Send" extension in the labs section (Settings, labs, search for "Undo Send"). It will delay the email delivery for 10-30 seconds. Can't live without it anymore :)
Reply all
Reply to author
Forward
0 new messages