Bug #65591 Cluster/J doesn't support byte/short types as Primary Key
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)
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
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)