Return-Path: Delivered-To: apmail-incubator-general-archive@www.apache.org Received: (qmail 13172 invoked from network); 19 Mar 2009 01:22:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Mar 2009 01:22:15 -0000 Received: (qmail 35673 invoked by uid 500); 19 Mar 2009 00:54:14 -0000 Delivered-To: apmail-incubator-general-archive@incubator.apache.org Received: (qmail 35477 invoked by uid 500); 19 Mar 2009 00:54:14 -0000 Mailing-List: contact general-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: general@incubator.apache.org Delivered-To: mailing list general@incubator.apache.org Received: (qmail 35463 invoked by uid 99); 19 Mar 2009 00:54:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Mar 2009 17:54:13 -0700 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [192.18.43.132] (HELO sca-es-mail-1.sun.com) (192.18.43.132) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Mar 2009 00:54:05 +0000 Received: from fe-sfbay-09.sun.com ([192.18.43.129]) by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id n2J0ri5O019308 for ; Wed, 18 Mar 2009 17:53:44 -0700 (PDT) MIME-version: 1.0 Received: from conversion-daemon.fe-sfbay-09.sun.com by fe-sfbay-09.sun.com (Sun Java(tm) System Messaging Server 7.0-5.01 64bit (built Feb 19 2009)) id <0KGQ00H00A6XVE00@fe-sfbay-09.sun.com> for general@incubator.apache.org; Wed, 18 Mar 2009 17:53:44 -0700 (PDT) Received: from [192.168.0.12] (c-98-207-88-57.hsd1.ca.comcast.net [98.207.88.57]) by fe-sfbay-09.sun.com (Sun Java(tm) System Messaging Server 7.0-5.01 64bit (built Feb 19 2009)) with ESMTPSA id <0KGQ00AYAAH7X250@fe-sfbay-09.sun.com> for general@incubator.apache.org; Wed, 18 Mar 2009 17:53:31 -0700 (PDT) Date: Wed, 18 Mar 2009 17:53:30 -0700 From: Craig L Russell Subject: If you're not interested in Java and MySQL Cluster, you can stop reading now... Sender: Craig.Russell@Sun.COM To: Incubator Message-id: <03C5B1FC-AF95-4046-A795-A5CEC52DC743@SUN.com> X-Mailer: Apple Mail (2.930.3) Content-type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha1; boundary=Apple-Mail-41--728710291 X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-41--728710291 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable I'm working (day job!) on a Java interface to the MySQL Cluster =20 database (a.k.a. NDB). NDB is a high performance, high availability =20 database used mostly in telecommunications applications. It can be the =20= backing store for a MySQL server (accessed via any of the MySQL client =20= APIs such as ODBC, JDBC) or can be used directly via primitive C++ or =20= Java APIs. What I've been developing is a high performance, easy-to-use Java =20 interface to NDB that bypasses the MySQL Server and instead goes =20 directly to the native NDB API. I've used a Domain Object Model =20 similar to Hibernate, JDO, and JPA. I'd like to work on this in Apache and would like to discuss the =20 opportunities with folks at ApacheCon. If this looks interesting, =20 please let me know. I'll post a proposal to the incubator wiki if =20 there is positive feedback. All work is done through a Session instance, which is the primary =20 application interface between the user and the database. The user acquires a Session instance from a SessionFactory, which in =20 turn is obtained via Services lookup. The factory is configured via =20 Properties, such as: com.mysql.clusterj.connectstring=3D127.0.0.1:9311 com.mysql.clusterj.mysqld=3Dlocalhost com.mysql.clusterj.username=3Droot com.mysql.clusterj.password=3D com.mysql.clusterj.testDatabase=3Dtest The Session interface provides methods for insert, delete, query, and =20= update. A separate Transaction interface provides methods for transaction =20 completion. The Transaction provides isActive(), begin(), commit(), =20 rollback(), setRollbackOnly(), and getRollbackOnly() methods. Two modes of operation are implemented: autocommit on/off. =95 With autocommit off: =95 when a mutating operation is invoked on the Session, = the =20 Transaction must be active, or an exception is thrown; and =95 when a non-mutating operation is invoked when a = Transaction is not =20 active, a transaction is begun and committed for the purpose of =20 executing the operation. =95 With autocommit on: =95 when a mutating operation is invoked on the Session, = the =20 Transaction is begun and committed for the operation; and =95 when a non-mutating operation is invoked, a = transaction is begun =20 and committed for the purpose of executing the operation. Deferred operation is proposed. By setting the flag =20 com.mysql.clusterj.defer.changes, mutating operations are deferred =20 until the Transaction is committed or the state is flushed via =20 Session.flush(). With defer changes, find() operations return a proxy =20= instance whose persistent properties are not initialized until the =20 user asks for one of them. Inserted instances are not actually sent to =20= the back end until the session is flushed. Deleted instances are not =20 deleted until the session is flushed. Queries return a Results =20 instance that is not instantiated until the user asks for a property =20 of an instance. For ease of use, users can define JavaBeans-pattern interfaces to =20 represent data, with annotations to declare database metadata: @PersistenceCapable(table=3D"t_basic") interface Employee { @PrimaryKey int getId(); void setId(int id); String getName(); void setName(String name); } The Session.newInstance(Class cls) is a factory for instances that =20 implement the user interface as well as a high-performance data access =20= path for the implementation. For JPA/JDO StorageManager, the high-=20 performance data access path is used. // Sample code to create a SessionFactory from a properties instance protected void createSessionFactory() { loadProperties(); if (sessionFactory =3D=3D null) { sessionFactory =3D ClusterJHelper.getSessionFactory(props); } loadSchema(); } // Sample code to delete and create instances public void localSetUp() { createSessionFactory(); session =3D sessionFactory.getSession(); createEmployeeInstances(NUMBER_TO_INSERT); tx =3D session.currentTransaction(); int count =3D 0; for (int i =3D 0; i < NUMBER_TO_INSERT; ++i) { tx.begin(); session.deletePersistent(employees.get(i)); try { tx.commit(); ++count; } catch (Exception ex) { // ignore exceptions -- might not be any instances to =20= delete } } addTearDownClasses(Employee.class); // System.out.println("Deleted " + count + " instances."); } public void testInsert() { tx =3D session.currentTransaction(); tx.begin(); for (int i =3D 0; i < NUMBER_TO_INSERT; ++i) { // must be done with an active transaction session.makePersistent(employees.get(i)); } tx.commit(); } } // Sample query code public void primaryKeyGreaterThanQuery() { tx.begin(); // QueryBuilder is the sessionFactory for queries QueryBuilder builder =3D session.getQueryBuilder(); // DomainObject is the main interface DomainObject dobj =3D =20 builder.createQueryDefinition(Employee.class); // parameter name PredicateOperand param =3D dobj.param("id"); // property name PredicateOperand column =3D dobj.get("id"); // compare the column with the parameter Predicate compare =3D column.greaterThan(param); // set the where clause into the query dobj.where(compare); // create a query instance Query query =3D session.createQuery(dobj); // set the parameter values query.setParameter("id", 6); // get the results List results =3D query.getResultList(); // consistency check the results consistencyCheck(results); // verify we got the right instances Set expected =3D new HashSet(); expected.add(7); expected.add(8); expected.add(9); Set actual =3D new HashSet(); for (Employee emp: results) { actual.add(emp.getId()); } errorIfNotEqual("Wrong employee ids returned from query: ", expected, actual); tx.commit(); } Craig L Russell Architect, Sun Java Enterprise System http://db.apache.org/jdo 408 276-5638 mailto:Craig.Russell@sun.com P.S. A good JDO? O, Gasp! --Apple-Mail-41--728710291 Content-Disposition: attachment; filename=smime.p7s Content-Type: application/pkcs7-signature; name=smime.p7s Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGUDCCAwkw ggJyoAMCAQICEDXZ+Ig/3d9DjJZ8u++ZnC0wDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA4MTIwOTE4MTYwMloXDTA5MTIwOTE4MTYw MlowbDEQMA4GA1UEBBMHUnVzc2VsbDEUMBIGA1UEKhMLQ3JhaWcgTGFpcmQxHDAaBgNVBAMTE0Ny YWlnIExhaXJkIFJ1c3NlbGwxJDAiBgkqhkiG9w0BCQEWFUNyYWlnLlJ1c3NlbGxAU3VuLkNPTTCC ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOe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