001    /*
002     * Copyright 2004 Chris Nelson
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
007     * Unless required by applicable law or agreed to in writing,
008     * software distributed under the License is distributed on an "AS IS" BASIS,
009     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010     * See the License for the specific language governing permissions and limitations under the License.
011     */
012    package org.trails.persistence;
013    
014    import java.util.List;
015    
016    import org.hibernate.criterion.DetachedCriteria;
017    import org.trails.descriptor.IClassDescriptor;
018    
019    
020    public interface HibernatePersistenceService extends PersistenceService
021    {
022    
023            public <T> T getInstance(Class<T> type, DetachedCriteria criteria);
024            public <T> List<T> getInstances(Class<T> type, DetachedCriteria criteria);
025            public <T> List<T> getInstances(Class<T> type, DetachedCriteria criteria, int startIndex, int maxResults);
026    
027            public int count(Class type, DetachedCriteria criteria);
028    
029            /**
030             * @param model to attach to the current persistence session
031             */
032            public void reattach(Object model);
033    
034            /**
035             * Does a query by example
036             *
037             * @param example
038             * @return
039             */
040            public <T> List<T> getInstances(T example, IClassDescriptor classDescriptor);
041    
042            public <T> T merge(T instance);
043    
044            public <T> T saveOrUpdate(T instance);
045            
046            public List find(String queryString);
047            public List find(String queryString, Object value);
048            public List find(String queryString, Object[] values);
049    }