Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.OpenJPAId


                throw new ClusterJDatastoreException(local.message("ERR_Datastore_Exception"), e);
            }
        }
        // otherwise, load from the datastore
        // TODO: support user-defined oid types
        OpenJPAId id = (OpenJPAId)sm.getId();
        if (logger.isTraceEnabled()) {
            logger.trace("Id: " + id.getClass() + " " + id);
        }
        // get domain type handler for StateManager
        NdbOpenJPADomainTypeHandlerImpl<?> domainTypeHandler = getDomainTypeHandler(sm);

        if (!isSupportedType(domainTypeHandler, "NdbOpenJPAStoreManager.initialize")) {
            // if not supported, go the jdbc route
            boolean result = super.initialize(sm, state, fetch, context);
            if (logger.isDebugEnabled()) logger.debug(
                    "NdbOpenJPAStoreManager.initialize delegated to super: returned " + result);
            return result;
        }
        try {
            // get session from session factory
            getSession();
            session.startAutoTransaction();
            // get domain type handler for StateManager
//            NdbOpenJPADomainTypeHandlerImpl<?> domainTypeHandler =
//                    getDomainTypeHandler(sm);
//                Object instance = session.initializeFromDatabase(
//                    domainTypeHandler, null,
//                    domainTypeHandler.getValueHandler(sm),
//                    domainTypeHandler.createKeyValueHandler(id.getIdObject()));
                // initialize via OpenJPA protocol
                // select all columns from table
                ValueHandler keyValueHandler = domainTypeHandler.createKeyValueHandler(id.getIdObject());
                ResultData resultData = session.selectUnique(domainTypeHandler,
                        keyValueHandler,
                        null);
                // create an OpenJPA Result from the ndb result data
                NdbOpenJPAResult result = new NdbOpenJPAResult(resultData, domainTypeHandler, null);
View Full Code Here


        protected int getInt(Object objectId) {
            // get an int value from an objectId
            if (objectId instanceof IntId) {
                return ((IntId)objectId).getId();
            } else if (objectId instanceof OpenJPAId) {
                OpenJPAId openJPAId = (OpenJPAId)objectId;
                Object id = openJPAId.getIdObject();
                if (id instanceof Integer) {
                    return ((Integer)id).intValue();
                }
                throw new UnsupportedOperationException(
                        local.message("ERR_Unsupported_Object_Id_Type", "int key", "OpenJPAId"));
View Full Code Here

        protected long getLong(Object objectId) {
            // get a long value from an objectId
            if (objectId instanceof LongId) {
                return ((LongId)objectId).getId();
            } else if (objectId instanceof OpenJPAId) {
                OpenJPAId openJPAId = (OpenJPAId)objectId;
                Object id = openJPAId.getIdObject();
                if (id instanceof Long) {
                    return ((Long)id).longValue();
                }
                throw new UnsupportedOperationException(
                        local.message("ERR_Unsupported_Object_Id_Type", "long key", "OpenJPAId"));
View Full Code Here

        protected String getString(Object objectId) {
            // get a String value from an objectId
            if (objectId instanceof StringId) {
                return ((StringId)objectId).getId();
            } else if (objectId instanceof OpenJPAId) {
                OpenJPAId openJPAId = (OpenJPAId)objectId;
                Object id = openJPAId.getIdObject();
                if (id instanceof String) {
                    return (String)id;
                }
                throw new UnsupportedOperationException(
                        local.message("ERR_Unsupported_Object_Id_Type", "String key", "OpenJPAId"));
View Full Code Here

     * @param store the store manager
     * @return the result of executing a query for the related type based on this instance's primary key
     */
    private NdbOpenJPAResult queryRelated(OpenJPAStateManager sm, NdbOpenJPAStoreManager store) {
        // get the Oid object for this sm
        OpenJPAId openJPAId = (OpenJPAId)sm.getObjectId();
        Object thisOid = openJPAId.getIdObject();
        QueryDomainType<?> queryDomainType = store.createQueryDomainType(relatedType);
        if (logger.isDetailEnabled()) logger.detail("created query for " + queryDomainType.getType().getName());
        // query for related type equals this pk oid value
        Predicate predicate = queryDomainType.get(relatedFieldName).equal(queryDomainType.param(relatedFieldName));
        queryDomainType.where(predicate);
View Full Code Here

TOP

Related Classes of org.apache.openjpa.util.OpenJPAId

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.