-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from JavaWebStack/dev
Release 1.0.2
- Loading branch information
Showing
25 changed files
with
400 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package org.javawebstack.orm; | ||
|
||
import org.javawebstack.orm.query.Query; | ||
import org.javawebstack.orm.query.QueryGroup; | ||
|
||
public interface Accessible { | ||
<T extends Model> Query<T> access(Query<T> query, Object accessor); | ||
<T extends Model> QueryGroup<T> access(Query<T> query, QueryGroup<T> accessChecks, Object accessor); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.javawebstack.orm; | ||
|
||
import org.javawebstack.orm.wrapper.SQL; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class Session { | ||
|
||
private static ThreadLocal<Session> sessions = new ThreadLocal<>(); | ||
|
||
public static Session current() { | ||
return sessions.get(); | ||
} | ||
|
||
private SQL connection; | ||
|
||
private Session() { | ||
|
||
} | ||
|
||
public Session via(SQL connection) { | ||
this.connection = connection; | ||
return this; | ||
} | ||
|
||
public SQL getConnection() { | ||
return connection; | ||
} | ||
|
||
public static void session(Consumer<Session> consumer) { | ||
Session session = begin(); | ||
consumer.accept(session); | ||
end(); | ||
} | ||
|
||
public static Session begin() { | ||
Session session = new Session(); | ||
sessions.set(session); | ||
return session; | ||
} | ||
|
||
public static void end() { | ||
sessions.remove(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.