some reformatting and a new way to get vos into the system

This commit is contained in:
Alex Huang 2012-02-22 11:11:58 -08:00
parent 7f470e8d2a
commit 7c6932ef80
2 changed files with 357 additions and 328 deletions

View File

@ -1,15 +1,21 @@
// Copyright 2012 Citrix Systems, Inc. Licensed under the
// Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. Citrix Systems, Inc.
// reserves all rights not expressly granted by the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.async;
import java.io.File;

View File

@ -338,6 +338,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
return searchIncludingRemoved(sc, filter, lock, cache, false) ;
}
@Override
public List<T> searchIncludingRemoved(SearchCriteria<T> sc, final Filter filter, final Boolean lock,
final boolean cache, final boolean enable_query_cache) {
String clause = sc != null ? sc.getWhereClause() : null;
@ -1499,6 +1500,28 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
return entity;
}
@DB(txn=false)
protected T toVO(ResultSet result, boolean cache) throws SQLException {
T entity;
try {
entity = _entityBeanType.newInstance();
} catch (InstantiationException e1) {
throw new CloudRuntimeException("Unable to instantiate entity", e1);
} catch (IllegalAccessException e1) {
throw new CloudRuntimeException("Illegal Access", e1);
}
toEntityBean(result, entity);
if (cache && _cache != null) {
try {
_cache.put(new Element(_idField.get(entity), entity));
} catch (final Exception e) {
s_logger.debug("Can't put it in the cache", e);
}
}
return entity;
}
@DB(txn=false)
protected void toEntityBean(final ResultSet result, final T entity) throws SQLException {
ResultSetMetaData meta = result.getMetaData();
@ -1736,7 +1759,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
public SearchCriteria2 createSearchCriteria2() {
final T entity = (T)_searchEnhancer.create();
final Factory factory = (Factory)entity;
SearchCriteria2 sc = new SearchCriteria2(entity, (Class<T>)entity.getClass(), _allAttributes, this);
SearchCriteria2 sc = new SearchCriteria2(entity, entity.getClass(), _allAttributes, this);
factory.setCallback(0, sc);
return sc;
}