Package org.apache.openejb.jee.jpa

Examples of org.apache.openejb.jee.jpa.GeneratedValue


            // Sun doen't really support generated primary keys, so we need to add them by hand here
            Set<String> generatedPks = new HashSet<String>(Arrays.asList("BasicCmp2", "AOBasicCmp2", "EncCmp2", "Cmp2RmiIiop"));
            EntityMappings cmpMappings = appModule.getCmpMappings();
            for (Entity entity : cmpMappings.getEntity()) {
                if (generatedPks.contains(entity.getName())) {
                    entity.getAttributes().getId().get(0).setGeneratedValue(new GeneratedValue(GenerationType.IDENTITY));
                }
            }
            String actual = toString(cmpMappings);

            XMLUnit.setIgnoreWhitespace(true);
View Full Code Here


            // Sun doen't really support generated primary keys, so we need to add them by hand here
            Set<String> generatedPks = new HashSet<String>(Arrays.asList("BasicCmp2", "AOBasicCmp2", "EncCmp2", "Cmp2RmiIiop"));
            EntityMappings cmpMappings = appModule.getCmpMappings();
            for (Entity entity : cmpMappings.getEntity()) {
                if (generatedPks.contains(entity.getName())) {
                    entity.getAttributes().getId().get(0).setGeneratedValue(new GeneratedValue(GenerationType.IDENTITY));
                }
            }
            String actual = toString(cmpMappings);
            assertEquals(expected, actual);
        }
View Full Code Here

                Attributes attributes = entityData.entity.getAttributes();
                if (attributes != null && attributes.getId().size() == 1) {
                    Id id = attributes.getId().get(0);

                    // todo detect specific generation strategy
                    id.setGeneratedValue(new GeneratedValue(GenerationType.IDENTITY));
                }
            }

            for (QueryType query : bean.getQuery()) {
                NamedQuery namedQuery = new NamedQuery();
View Full Code Here

            mapping.addField(field);
            primaryKeyFields.add(fieldName);
        } else if ("java.lang.Object".equals(bean.getPrimKeyClass())) {
            String fieldName = "OpenEJB_pk";
            Id field = new Id(fieldName);
            field.setGeneratedValue(new GeneratedValue(GenerationType.AUTO));
            mapping.addField(field);
            primaryKeyFields.add(fieldName);
        } else if (bean.getPrimKeyClass() != null) {
            Class<?> pkClass = null;
            try {
View Full Code Here

            mapping.addField(new AttributeOverride(fieldName));
            primaryKeyFields.add(fieldName);
        } else if ("java.lang.Object".equals(bean.getPrimKeyClass())) {
            String fieldName = "OpenEJB_pk";
            Id field = new Id(fieldName);
            field.setGeneratedValue(new GeneratedValue(GenerationType.AUTO));
            mapping.addField(field);
        } else if (bean.getPrimKeyClass() != null) {
            Class<?> pkClass = null;
            try {
                pkClass = classLoader.loadClass(bean.getPrimKeyClass());
View Full Code Here

            // Sun doen't really support generated primary keys, so we need to add them by hand here
            Set<String> generatedPks = new HashSet<String>(Arrays.asList("BasicCmp2", "AOBasicCmp2", "EncCmp2", "Cmp2RmiIiop"));
            EntityMappings cmpMappings = appModule.getCmpMappings();
            for (Entity entity : cmpMappings.getEntity()) {
                if (generatedPks.contains(entity.getName())) {
                    entity.getAttributes().getId().get(0).setGeneratedValue(new GeneratedValue(GenerationType.IDENTITY));
                }
            }
            String actual = toString(cmpMappings);

            XMLUnit.setIgnoreWhitespace(true);
View Full Code Here

                Attributes attributes = entityData.entity.getAttributes();
                if (attributes != null && attributes.getId().size() == 1) {
                    Id id = attributes.getId().get(0);

                    // todo detect specific generation strategy
                    id.setGeneratedValue(new GeneratedValue(GenerationType.IDENTITY));
                }
            }

            for (QueryType query : bean.getQuery()) {
                NamedQuery namedQuery = new NamedQuery();
View Full Code Here

            // Sun doen't really support generated primary keys, so we need to add them by hand here
            Set<String> generatedPks = new HashSet<String>(Arrays.asList("BasicCmp2", "AOBasicCmp2", "EncCmp2", "Cmp2RmiIiop"));
            EntityMappings cmpMappings = appModule.getCmpMappings();
            for (Entity entity : cmpMappings.getEntity()) {
                if (generatedPks.contains(entity.getName())) {
                    entity.getAttributes().getId().get(0).setGeneratedValue(new GeneratedValue(GenerationType.IDENTITY));
                }
            }
            String actual = toString(cmpMappings);

            XMLUnit.setIgnoreWhitespace(true);
View Full Code Here

    try {
      String fieldName = id.getName();
      String methodName = convertFieldNameToGetterName(fieldName);
      String[] emptySignature = new String[0];
      facade.addMethodAnnotation(entityBean.getEjbClass(), methodName, emptySignature, javax.persistence.Id.class, null);
      GeneratedValue generatedValue = id.getGeneratedValue();
      if (generatedValue != null) {
        Map<String, Object> generatedValueProps = new HashMap<String, Object>();
        if (generatedValue.getGenerator() != null) {
          generatedValueProps.put("generator", generatedValue.getGenerator()); //$NON-NLS-1$
        }

        GenerationType strategy = generatedValue.getStrategy();
        switch (strategy) {
        case AUTO:
          generatedValueProps.put("strategy", javax.persistence.GenerationType.AUTO); //$NON-NLS-1$
          break;
        case IDENTITY:
View Full Code Here

            mapping.addField(field);
            primaryKeyFields.add(fieldName);
        } else if ("java.lang.Object".equals(bean.getPrimKeyClass())) {
            String fieldName = "OpenEJB_pk";
            Id field = new Id(fieldName);
            field.setGeneratedValue(new GeneratedValue(GenerationType.AUTO));
            mapping.addField(field);
            primaryKeyFields.add(fieldName);
        } else if (bean.getPrimKeyClass() != null) {
            Class<?> pkClass = null;
            try {
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.jpa.GeneratedValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.