Skip to content

Instantly share code, notes, and snippets.

View tylertreat's full-sized avatar

Tyler Treat tylertreat

View GitHub Profile
public class Department {
@PrimaryKey
private long id;
private String name;
@OneToMany(className = "com.foo.domain.Employee", name = "works-in", column = "dept")
private List<Employee> employees;
select * from department where id = 14
select * from employee where id = 4028
public class Employee {
@PrimaryKey
private long id;
private String name;
@ManyToOne(className = "com.foo.domain.Department", name = "works-in", column = "dept")
private Department department;
public static boolean isPrime(int p, int k) {
Random rand = new Random();
for (int i = 0; i < k; i++) {
int a = rand.nextInt(p - 1) + 1;
int pow = (int) Math.pow(a, p - 1);
if (pow % p != 1)
return false;
}
return true;
}
public static boolean isPrime(int p) {
Random rand = new Random();
int a = rand.nextInt(p - 1) + 1;
int pow = (int) Math.pow(a, p - 1);
return pow % p == 1;
}
public static boolean isPrime(int n) {
for (int i = 2; i < Math.floor(Math.sqrt(n)); i++) {
if (n % i == 0)
return false;
}
return true;
}
public static boolean isPrime(int n) {
for (int i = 2; i < n - 1; i++) {
if (n % i == 0)
return false;
}
return true;
}
private List<Bean> getClientStubBeans() {
String workingDir = System.getProperty("user.dir");
File stubDir = new File(workingDir + File.separator + "bin-test" + File.separator + "com\\foo\\client\\stub");
if (!stubDir.exists() || !stubDir.isDirectory()) {
logger.error("Unable to load client stubs");
return new ArrayList<Bean>();
}
return buildBeanDefinitions(stubDir);
}
private void addClasspathDependencies() {
String workingDir = System.getProperty("user.dir");
// We need to add these libs to appease the ClassLoader Gods
File lib = new File(workingDir + File.separator + "lib");
for (File file : lib.listFiles())
addToClasspath(file);
// Add bin-test to the class path -- this is where the stubs are
File binTest = new File(workingDir + File.separator + "bin-test");