mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - format code
This commit is contained in:
@@ -6,19 +6,19 @@ import com.avaje.tests.model.basic.Customer;
|
||||
|
||||
public class CustomerPersistAdapter extends BeanPersistAdapter {
|
||||
|
||||
@Override
|
||||
public boolean isRegisterFor(Class<?> cls) {
|
||||
return Customer.class.equals(cls);
|
||||
}
|
||||
@Override
|
||||
public boolean isRegisterFor(Class<?> cls) {
|
||||
return Customer.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preInsert(BeanPersistRequest<?> request) {
|
||||
|
||||
@Override
|
||||
public boolean preInsert(BeanPersistRequest<?> request) {
|
||||
|
||||
// StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||
// request.getTransaction().log("+++++ "+Arrays.toString(stackTrace));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preUpdate(BeanPersistRequest<?> request) {
|
||||
|
||||
@@ -7,24 +7,24 @@ import com.avaje.tests.model.basic.TOne;
|
||||
|
||||
public class SimpleTOneQueryAdapter implements BeanQueryAdapter {
|
||||
|
||||
public int getExecutionOrder() {
|
||||
// just return 0
|
||||
return 0;
|
||||
}
|
||||
public int getExecutionOrder() {
|
||||
// just return 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isRegisterFor(Class<?> cls) {
|
||||
return TOne.class.equals(cls);
|
||||
}
|
||||
public boolean isRegisterFor(Class<?> cls) {
|
||||
return TOne.class.equals(cls);
|
||||
}
|
||||
|
||||
public void preQuery(BeanQueryRequest<?> request) {
|
||||
|
||||
Query<?> query = request.getQuery();
|
||||
|
||||
// can get the type of query Bean, List, RowCount, Id's etc
|
||||
//Type queryType = query.getType();
|
||||
|
||||
query.where().raw("1=1");
|
||||
}
|
||||
|
||||
public void preQuery(BeanQueryRequest<?> request) {
|
||||
|
||||
Query<?> query = request.getQuery();
|
||||
|
||||
// can get the type of query Bean, List, RowCount, Id's etc
|
||||
//Type queryType = query.getType();
|
||||
|
||||
query.where().raw("1=1");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Finder methods for Customer.
|
||||
*/
|
||||
public class CustomerFinder extends Finder<Integer,Customer> {
|
||||
public class CustomerFinder extends Finder<Integer, Customer> {
|
||||
|
||||
public CustomerFinder() {
|
||||
super(Customer.class);
|
||||
|
||||
@@ -6,7 +6,7 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@AttributeOverride(name="name", column=@Column(name = "mod_name"))
|
||||
@AttributeOverride(name = "name", column = @Column(name = "mod_name"))
|
||||
@Entity
|
||||
@Table(name = "f_second")
|
||||
public class Second extends SuperSecond {
|
||||
|
||||
@@ -10,7 +10,7 @@ public abstract class SuperSecond {
|
||||
|
||||
protected String name;
|
||||
|
||||
@OneToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
|
||||
@OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@JoinColumn(name = "first")
|
||||
protected First first;
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.avaje.tests.model.basic.first;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestFirstSecond extends BaseTestCase {
|
||||
|
||||
@@ -20,7 +19,7 @@ public class TestFirstSecond extends BaseTestCase {
|
||||
second.setFirst(first);
|
||||
Ebean.save(second);
|
||||
|
||||
|
||||
|
||||
second.getFirst().setName("changed");
|
||||
Ebean.save(second);
|
||||
Ebean.save(first);
|
||||
|
||||
@@ -5,12 +5,12 @@ import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class MapSuperActual extends MapSuperNoId {
|
||||
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
|
||||
String name;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -26,5 +26,5 @@ public class MapSuperActual extends MapSuperNoId {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.avaje.tests.model.basic.mapsuper;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import com.avaje.ebean.annotation.CreatedTimestamp;
|
||||
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Version;
|
||||
|
||||
import com.avaje.ebean.annotation.CreatedTimestamp;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@MappedSuperclass
|
||||
public class MapSuperNoId {
|
||||
|
||||
@CreatedTimestamp
|
||||
Timestamp whenCreated;
|
||||
|
||||
|
||||
@Version
|
||||
Timestamp whenUpdated;
|
||||
|
||||
@@ -31,5 +30,5 @@ public class MapSuperNoId {
|
||||
public void setWhenUpdated(Timestamp whenUpdated) {
|
||||
this.whenUpdated = whenUpdated;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.avaje.tests.model.basic.mapsuper;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestMapSuperEquals extends BaseTestCase {
|
||||
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
package com.avaje.tests.model.basic.xtra;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
|
||||
import com.avaje.ebean.config.PersistBatch;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.Transaction;
|
||||
import com.avaje.ebean.TxType;
|
||||
import com.avaje.ebean.annotation.Transactional;
|
||||
import com.avaje.ebean.config.PersistBatch;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DummyDao {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(DummyDao.class);
|
||||
|
||||
|
||||
@Transactional(type = TxType.REQUIRES_NEW)
|
||||
public void doSomething() {
|
||||
|
||||
|
||||
logger.info(" --- in DummyDao.doSomething() with TxType.REQUIRES_NEW");
|
||||
Transaction txn = Ebean.currentTransaction();
|
||||
if (txn == null) {
|
||||
logger.error(" NO TRANSACTION ??");
|
||||
} else {
|
||||
logger.info(" --- txn - "+txn);
|
||||
logger.info(" --- txn - " + txn);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -8,40 +8,40 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="td_child")
|
||||
@Table(name = "td_child")
|
||||
public class EdChild {
|
||||
@Id
|
||||
@Column(name="child_id")
|
||||
private int id;
|
||||
@Id
|
||||
@Column(name = "child_id")
|
||||
private int id;
|
||||
|
||||
@Column(name="child_name")
|
||||
private String name;
|
||||
@Column(name = "child_name")
|
||||
private String name;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="parent_id", nullable=false )
|
||||
EdParent parent;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "parent_id", nullable = false)
|
||||
EdParent parent;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public EdParent getParent() {
|
||||
return parent;
|
||||
}
|
||||
public EdParent getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(EdParent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
public void setParent(EdParent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@ import javax.persistence.Entity;
|
||||
@DiscriminatorValue("EXTENDED")
|
||||
public class EdExtendedParent extends EdParent {
|
||||
|
||||
private String extendedName;
|
||||
private String extendedName;
|
||||
|
||||
public String getExtendedName() {
|
||||
return extendedName;
|
||||
}
|
||||
public String getExtendedName() {
|
||||
return extendedName;
|
||||
}
|
||||
|
||||
public void setExtendedName(String extendedName) {
|
||||
this.extendedName = extendedName;
|
||||
}
|
||||
public void setExtendedName(String extendedName) {
|
||||
this.extendedName = extendedName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
|
||||
package com.avaje.tests.model.basic.xtra;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
@@ -16,45 +13,46 @@ import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING , name="parent_type")
|
||||
@DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "parent_type")
|
||||
@DiscriminatorValue("BASIC")
|
||||
@Table(name="td_parent")
|
||||
@Table(name = "td_parent")
|
||||
public class EdParent {
|
||||
@Id
|
||||
@Column(name="parent_id")
|
||||
private int id;
|
||||
@Id
|
||||
@Column(name = "parent_id")
|
||||
private int id;
|
||||
|
||||
@Column(name="parent_name")
|
||||
private String name;
|
||||
@Column(name = "parent_name")
|
||||
private String name;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy="parent", cascade=CascadeType.ALL)
|
||||
List<EdChild> children;
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "parent", cascade = CascadeType.ALL)
|
||||
List<EdChild> children;
|
||||
|
||||
public List<EdChild> getChildren() {
|
||||
return children;
|
||||
}
|
||||
public List<EdChild> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<EdChild> children) {
|
||||
this.children = children;
|
||||
}
|
||||
public void setChildren(List<EdChild> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+33
-33
@@ -1,47 +1,47 @@
|
||||
package com.avaje.tests.model.basic.xtra;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.SqlUpdate;
|
||||
import com.avaje.ebean.Transaction;
|
||||
import com.avaje.ebean.annotation.Transactional;
|
||||
import com.avaje.tests.model.basic.EBasicVer;
|
||||
import org.junit.Assert;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
public class OptimisticLockExceptionThrowingDao {
|
||||
|
||||
Transaction inMethodTransaction;
|
||||
|
||||
@Transactional
|
||||
public void doSomething(EBasicVer v) {
|
||||
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
|
||||
inMethodTransaction = server.currentTransaction();
|
||||
|
||||
Transaction t = server.createTransaction();
|
||||
SqlUpdate u = server.createSqlUpdate("update e_basicver set last_update = last_update+1 where id = ?");
|
||||
u.setParameter(1, v.getId());
|
||||
int count = server.execute(u, t);
|
||||
Assert.assertEquals(1, count);
|
||||
|
||||
t.commit();
|
||||
|
||||
v.setName("some change");
|
||||
try {
|
||||
Ebean.save(v);
|
||||
// never get here
|
||||
Assert.assertTrue(false);
|
||||
} catch (PersistenceException e){
|
||||
throw e;
|
||||
}
|
||||
|
||||
Transaction inMethodTransaction;
|
||||
|
||||
@Transactional
|
||||
public void doSomething(EBasicVer v) {
|
||||
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
|
||||
inMethodTransaction = server.currentTransaction();
|
||||
|
||||
Transaction t = server.createTransaction();
|
||||
SqlUpdate u = server.createSqlUpdate("update e_basicver set last_update = last_update+1 where id = ?");
|
||||
u.setParameter(1, v.getId());
|
||||
int count = server.execute(u, t);
|
||||
Assert.assertEquals(1, count);
|
||||
|
||||
t.commit();
|
||||
|
||||
v.setName("some change");
|
||||
try {
|
||||
Ebean.save(v);
|
||||
// never get here
|
||||
Assert.assertTrue(false);
|
||||
} catch (PersistenceException e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
public Transaction getInMethodTransaction() {
|
||||
return inMethodTransaction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Transaction getInMethodTransaction() {
|
||||
return inMethodTransaction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.avaje.tests.model.basic.xtra;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.SqlUpdate;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TestDeleteUnloadedChildren extends BaseTestCase {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user