Search in sources :

Example 1 with ComplexKeyGenerator

use of org.apache.openejb.core.cmp.ComplexKeyGenerator in project tomee by apache.

the class JpaCmpEngine method configureKeyGenerator.

private void configureKeyGenerator(final BeanContext di) throws OpenEJBException {
    if (di.isCmp2()) {
        di.setKeyGenerator(new Cmp2KeyGenerator());
    } else {
        final String primaryKeyField = di.getPrimaryKeyField();
        final Class cmpBeanImpl = di.getCmpImplClass();
        if (primaryKeyField != null) {
            di.setKeyGenerator(new SimpleKeyGenerator(cmpBeanImpl, primaryKeyField));
        } else if (Object.class.equals(di.getPrimaryKeyClass())) {
            di.setKeyGenerator(new SimpleKeyGenerator(cmpBeanImpl, "OpenEJB_pk"));
        } else {
            di.setKeyGenerator(new ComplexKeyGenerator(cmpBeanImpl, di.getPrimaryKeyClass()));
        }
    }
}
Also used : Cmp2KeyGenerator(org.apache.openejb.core.cmp.cmp2.Cmp2KeyGenerator) ComplexKeyGenerator(org.apache.openejb.core.cmp.ComplexKeyGenerator) SimpleKeyGenerator(org.apache.openejb.core.cmp.SimpleKeyGenerator) EJBObject(javax.ejb.EJBObject) EJBLocalObject(javax.ejb.EJBLocalObject)

Aggregations

EJBLocalObject (javax.ejb.EJBLocalObject)1 EJBObject (javax.ejb.EJBObject)1 ComplexKeyGenerator (org.apache.openejb.core.cmp.ComplexKeyGenerator)1 SimpleKeyGenerator (org.apache.openejb.core.cmp.SimpleKeyGenerator)1 Cmp2KeyGenerator (org.apache.openejb.core.cmp.cmp2.Cmp2KeyGenerator)1