2 Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 package com.mysql.clusterj.jpatest;
20 import com.mysql.clusterj.jpatest.model.Embedded;
21 import com.mysql.clusterj.jpatest.model.Embedding;
22 import com.mysql.clusterj.jpatest.model.IdBase;
25 /** Test Embedded class support. Currently only remove and insert are tested.
29 drop table if exists t_basic;
30 create table t_basic (
32 name varchar(32), // embedded
37 create unique index idx_unique_hash_magic using hash on t_basic(magic);
38 create index idx_btree_age on t_basic(age);
42 public class EmbeddedTest extends AbstractJPABaseTest {
44 private int NUMBER_OF_INSTANCES = 10;
47 protected boolean getDebug() {
51 /** Subclasses must override this method to provide the model class for the test */
52 protected Class<? extends IdBase> getModelClass() {
53 return Embedding.class;
57 * The name of the persistence unit that this test class should use
58 * by default. This defaults to "ndb".
61 protected String getPersistenceUnitName() {
66 removeAll(Embedding.class);
67 em.getTransaction().begin();
68 for (int i = 0; i < NUMBER_OF_INSTANCES ; ++i) {
69 Embedding e = createEmbedding(i);
72 em.getTransaction().commit();
75 private Embedding createEmbedding(int i) {
76 Embedded embedded = new Embedded();
78 embedded.setName("Embedded " + i);
79 Embedding embedding = new Embedding();
81 embedding.setMagic(i);
82 embedding.setEmbedded(embedded);