All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rapidoidx.db.Database Maven / Gradle / Ivy

The newest version!
package org.rapidoidx.db;

/*
 * #%L
 * rapidoid-x-db
 * %%
 * Copyright (C) 2014 - 2015 Nikolche Mihajlovski and contributors
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) 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 Affero General Public License
 * along with this program.  If not, see .
 * #L%
 */

import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

import org.rapidoid.activity.Activity;
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.concurrent.Callback;
import org.rapidoid.lambda.Operation;
import org.rapidoid.lambda.Predicate;

@Authors("Nikolche Mihajlovski")
@Since("3.0.0")
public interface Database extends Activity {

	void loadAndStart();

	long insert(Object record);

	 E get(long id);

	 E getIfExists(long id);

	 E get(long id, Class clazz);

	 List getAll(Class clazz);

	 List getAll(long... ids);

	 List getAll(Collection ids);

	 void refresh(E record);

	void update(Object record);

	void update(long id, Object record);

	long persist(Object record);

	long persistedIdOf(Object record);

	void delete(long id);

	void delete(Object record);

	 T readColumn(long id, String column);

	 List find(Predicate match);

	 List find(Iterable ids);

	 List find(Class clazz, Predicate match, Comparator orderBy);

	 List find(String searchPhrase);

	 List find(Class clazz, String query, Object... args);

	 void each(Operation lambda);

	void transaction(Runnable transaction, boolean readOnly);

	void transaction(Runnable transaction, boolean readOnly, Callback callback);

	void saveTo(OutputStream output);

	void load(InputStream in);

	long size();

	void clear();

	void destroy();

	long getIdOf(Object record);

	long getVersionOf(long id);

	 DbColumn column(Map map, String name, Class type);

	 DbList list(Object holder, String relation);

	 DbSet set(Object holder, String relation);

	 DbRef ref(Object holder, String relation);

	DbSchema schema();

	Database as(String username);

	Database sudo();

	void init(String data, Object... args);

	 RESULT rql(String rql, Object... args);

	 E entity(String rql, Object... args);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy