001    package org.cumulus4j.store.model;
002    
003    import javax.jdo.JDOObjectNotFoundException;
004    import javax.jdo.PersistenceManager;
005    
006    public class ClassMetaDAO extends AbstractDAO {
007    
008            public ClassMetaDAO() { }
009    
010            public ClassMetaDAO(PersistenceManager pm) {
011                    super(pm);
012            }
013    
014            public ClassMeta getClassMeta(String packageName, String simpleClassName, boolean throwExceptionIfNotFound)
015            {
016                    javax.jdo.Query q = pm.newNamedQuery(ClassMeta.class, ClassMeta.NamedQueries.getClassMetaByPackageNameAndSimpleClassName);
017                    ClassMeta result = (ClassMeta) q.execute(packageName, simpleClassName);
018    
019                    if (result == null && throwExceptionIfNotFound)
020                            throw new JDOObjectNotFoundException(
021                                            "No ClassMeta found for packageName=\"" + packageName + "\" and simpleClassName=\"" + simpleClassName + "\"!"
022                            );
023    
024                    return result;
025            }
026    
027            public ClassMeta getClassMeta(Class<?> clazz, boolean throwExceptionIfNotFound)
028            {
029                    String packageName = clazz.getPackage() == null ? "" : clazz.getPackage().getName();
030                    String simpleClassName = clazz.getSimpleName();
031                    return getClassMeta(packageName, simpleClassName, throwExceptionIfNotFound);
032            }
033    }