I created table like that in MySQL:

DROP TABLE IF EXISTS `barcode`;
CREATE TABLE `barcode` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(40) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;


INSERT INTO `barcode` VALUES ('1', 'abc');

INSERT INTO `barcode` VALUES ('2', 'abc ');

Then I query data from table barcode:

SELECT * FROM barcode WHERE `code` = 'abc ';

The result is:

+-----+-------+
|  id | code  |
+-----+-------+
|  1  |  abc  |
+-----+-------+
|  2  |  abc  |
+-----+-------+

But I want the result set is only 1 record. I workaround with:

SELECT * FROM barcode WHERE `code` = binary 'abc ';

The result is 1 record. But I'm using NHibernate with MySQL for generating query from mapping table. So that how to resolve this case?

Edit
Report