Bug #65591 Cluster/J doesn't support byte/short types as Primary Key
Submitted: 12 Jun 2012 14:52 Modified: 29 Oct 2013 18:32
Reporter: Yura Zhyshko Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster/J Severity:S2 (Serious)
Version:7.2.6, 7.2.14 OS:Any
Assigned to: Craig Russell CPU Architecture:Any

[12 Jun 2012 14:52] Yura Zhyshko
Description:
Hi, everybody.

I was trying to move some queries to Cluster/J from JDBC for performance improvement. But faced some problems that Cluster/J doesn't support Byte/Short types as Primary Key. This is blocking our great movement.

Thanks.

How to repeat:
1. Create table:

CREATE  TABLE `jicore`.`test_table` (

  `id` TINYINT NOT NULL ,

  `name` VARCHAR(45) NULL ,

  PRIMARY KEY (`id`) )

ENGINE = ndbcluster;

2. Add data:

INSERT INTO `jicore`.`test_table` (`id`, `name`) VALUES (1, 'test');

3. TestTable.java

import com.mysql.clusterj.annotation.PersistenceCapable;
import com.mysql.clusterj.annotation.PrimaryKey;

@PersistenceCapable(table = "test_table")
public interface TestTable {

	@PrimaryKey
	byte getId();

	void setid(byte id);

	String getName();

	void setName(String name);

}

4. ClusterJTest.java:

import java.util.HashMap;
import java.util.Map;

import com.mysql.clusterj.ClusterJHelper;
import com.mysql.clusterj.Session;
import com.mysql.clusterj.SessionFactory;

public class ClusterJTest {

	public static void main(String[] args) {
		Map<String, String> props = new HashMap<String, String>();
		props.put("com.mysql.clusterj.connectstring",
				"db-23.jiwiredev.com:1186");
		props.put("com.mysql.clusterj.database", "jicore");
		props.put("com.mysql.clusterj.connection.pool.size", "1");
		SessionFactory sessionFactory = ClusterJHelper.getSessionFactory(props);
		Session session = sessionFactory.getSession();
		TestTable table = session.find(TestTable.class, 1);
		System.out.println(table.getId());
		session.close();
		sessionFactory.close();
	}

}

5. Compile and Run ClusterJTest:

Jun 12, 2012 10:19:36 AM com.mysql.clusterj.core.metadata.DomainTypeHandlerFactoryImpl createDomainTypeHandler
INFO: Removing schema test_table after failure to initialize domain type handler for class com.jiwire.jane.TestTable.
Exception in thread "main" com.mysql.clusterj.ClusterJUserException: Error in metadata initialization for com.jiwire.jane.TestTable:
The field id in class com.jiwire.jane.TestTable cannot be persistent:
For class com.jiwire.jane.TestTable, primary key column id: field type byte is not supported.
For class com.jiwire.jane.TestTable, field id, column id, index PRIMARY, type hash: hash indexes on float and double; and indexes on lob types are not supported.
For class com.jiwire.jane.TestTable, field id, column id, index PRIMARY, type btree: hash indexes on float and double; and indexes on lob types are not supported.

	at com.mysql.clusterj.core.metadata.DomainTypeHandlerImpl.<init>(DomainTypeHandlerImpl.java:261)
	at com.mysql.clusterj.core.metadata.DomainTypeHandlerFactoryImpl.createDomainTypeHandler(DomainTypeHandlerFactoryImpl.java:79)
	at com.mysql.clusterj.core.SessionFactoryImpl.getDomainTypeHandler(SessionFactoryImpl.java:346)
	at com.mysql.clusterj.core.SessionImpl.getDomainTypeHandler(SessionImpl.java:1133)
	at com.mysql.clusterj.core.SessionImpl.find(SessionImpl.java:166)
	at com.jiwire.jane.ClusterJTest.main(ClusterJTest.java:20)
[14 Jun 2012 22:49] Yura Zhyshko
Changed priority
[19 Jun 2012 23:00] Yura Zhyshko
Does anybody respond on this ????????????????????
[22 Jul 2013 21:05] Sveta Smirnova
Thank you for the report.

Verified as described. And I can not find this issue mentioned at http://dev.mysql.com/doc/ndbapi/en/mccj-issues.html
[29 Oct 2013 18:32] Craig Russell
This issues was fixed and is available with 7.3.3, 7.2.14, and 7.1.29