ObjectDB ObjectDB

Issue #1699: Feature Request: Subclassed PersistenceException for Type Not Found in DB Schema

Type: Feature RequestVersion: 2.6.3Priority: NormalStatus: ClosedReplies: 3
#1

Hi,
Our application uses a sharding strategy with ObjectDB.  We have numerous ODB files with different schemas managed by the same ObjectDB server that are sharded based on the day.  We let ObjectdDB create the schema in each ODB file the first time objects are persisted.  The problem is that when a process runs that querys a shard before the schema is created a generic PersistenceException is thrown.  For us, and I assume many other users, this isn’t a problem and we would like our application to behave like the query returned nothing.  We can’t implement this behavior in our application without parsing the exception text.  It would be very nice if this particular exception were a type/subclass of PersistenceException that we can catch and handle differently than more critical PersistenceExceptions. 

Please consider this suggestion and let me know if this is something that can be done or if you have alternative solutions to the problem.

Thank you,

Clinton Moore

 

com.adheris.cap.summaryframework.entities.daos.SummaryArchiveDAO:206 -> Query failed due to
TEX: Type AbstractClientSummary is not found
com.objectdb.o._PersistenceException:45
com.objectdb.o.JPE:145
com.objectdb.o.ERR:56
com.objectdb.o.OBC:1503
com.objectdb.jpa.JpaQuery:725
com.adheris.cap.summaryframework.entities.daos.SummaryArchiveDAO:204
com.adheris.cap.loggingservices.AbstractHLogService:74

One of the methods that returns this exception every day a before a new shard is created.
    public List<Integer> getDistinctStores(String chain) {

        List<Integer> storeList = new ArrayList<Integer>();

        String queryString = "select DISTINCT(summary.store) from AbstractClientSummary summary WHERE summary.chain == :chain";
        TypedQuery<Integer> query = manager.createQuery(queryString, Integer.class);
        query.setParameter("chain", Integer.parseInt(chain));
        try {
            storeList = query.getResultList();
        } catch (PersistenceException e) {
            logger.error("Query failed due to {}", ExceptionAssistant.getStackTrace(e));
        }

edit
delete
#2

This feature request is related to the following posts:

https://stackoverflow.com/questions/20752124/problems-searching-empty-user-database-with-objectdb

http://www.objectdb.com/database/forum/68

http://www.objectdb.com/database/forum/1098

Have you tried the solutions in these posts? It may be better to avoid this exception by introducing the relevant classes to ObjectDB before the first query. If you still have to catch these exceptions, maybe you can identify them by getCause(), since the underlying exception could be different.

 

ObjectDB Support
edit
delete
#3

Thank you very much for your help!  This issue is resolved.

Introducing the type to the database prior to the query worked as suggested.

manager.getMetamodel().managedType(AbstractClientSummary.class);

edit
delete
#4

Good. So this feature request will be closed.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.