-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample code for comparison with MyBatis
- Loading branch information
1 parent
7be6754
commit 63f2a5e
Showing
11 changed files
with
504 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
integration-test-java/src/main/java/org/seasar/doma/it/temp/Category.java
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,31 @@ | ||
package org.seasar.doma.it.temp; | ||
|
||
import org.seasar.doma.Entity; | ||
import org.seasar.doma.Id; | ||
import org.seasar.doma.Table; | ||
|
||
import java.io.Serializable; | ||
|
||
@Entity | ||
@Table(name = "m_category") | ||
public class Category implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
@Id private String code; | ||
private String name; | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
integration-test-java/src/main/java/org/seasar/doma/it/temp/Coupon.java
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,41 @@ | ||
package org.seasar.doma.it.temp; | ||
|
||
import org.seasar.doma.Entity; | ||
import org.seasar.doma.Id; | ||
import org.seasar.doma.Table; | ||
|
||
import java.io.Serializable; | ||
|
||
@Entity | ||
@Table(name = "m_coupon") | ||
public class Coupon implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
@Id | ||
private String code; | ||
private String name; | ||
private int price; | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getPrice() { | ||
return price; | ||
} | ||
|
||
public void setPrice(int price) { | ||
this.price = price; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
integration-test-java/src/main/java/org/seasar/doma/it/temp/Item.java
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,52 @@ | ||
package org.seasar.doma.it.temp; | ||
|
||
import org.seasar.doma.Association; | ||
import org.seasar.doma.Entity; | ||
import org.seasar.doma.Id; | ||
import org.seasar.doma.Table; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Table(name = "m_item") | ||
public class Item implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
@Id private String code; | ||
private String name; | ||
private int price; | ||
@Association private List<Category> categories = new ArrayList<>(); | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getPrice() { | ||
return price; | ||
} | ||
|
||
public void setPrice(int price) { | ||
this.price = price; | ||
} | ||
|
||
public List<Category> getCategories() { | ||
return categories; | ||
} | ||
|
||
public void setCategories(List<Category> categories) { | ||
this.categories = categories; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
integration-test-java/src/main/java/org/seasar/doma/it/temp/Order.java
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,53 @@ | ||
package org.seasar.doma.it.temp; | ||
|
||
import org.seasar.doma.Association; | ||
import org.seasar.doma.Entity; | ||
import org.seasar.doma.Id; | ||
import org.seasar.doma.Table; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Table(name = "t_order") | ||
public class Order implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
@Id | ||
private int id; | ||
@Association private OrderStatus orderStatus; | ||
@Association List<OrderItem> orderItems = new ArrayList<>(); | ||
@Association List<OrderCoupon> orderCoupons = new ArrayList<>(); | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public OrderStatus getOrderStatus() { | ||
return orderStatus; | ||
} | ||
|
||
public void setOrderStatus(OrderStatus orderStatus) { | ||
this.orderStatus = orderStatus; | ||
} | ||
|
||
public List<OrderItem> getOrderItems() { | ||
return orderItems; | ||
} | ||
|
||
public void setOrderItems(List<OrderItem> orderItems) { | ||
this.orderItems = orderItems; | ||
} | ||
|
||
public List<OrderCoupon> getOrderCoupons() { | ||
return orderCoupons; | ||
} | ||
|
||
public void setOrderCoupons(List<OrderCoupon> orderCoupons) { | ||
this.orderCoupons = orderCoupons; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
integration-test-java/src/main/java/org/seasar/doma/it/temp/OrderCoupon.java
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,43 @@ | ||
package org.seasar.doma.it.temp; | ||
|
||
import org.seasar.doma.Association; | ||
import org.seasar.doma.Entity; | ||
import org.seasar.doma.Id; | ||
import org.seasar.doma.Table; | ||
|
||
import java.io.Serializable; | ||
|
||
@Entity | ||
@Table(name = "t_order_coupon") | ||
public class OrderCoupon implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
@Id | ||
private int orderId; | ||
@Id | ||
private String couponCode; | ||
@Association private Coupon coupon; | ||
|
||
public int getOrderId() { | ||
return orderId; | ||
} | ||
|
||
public void setOrderId(int orderId) { | ||
this.orderId = orderId; | ||
} | ||
|
||
public String getCouponCode() { | ||
return couponCode; | ||
} | ||
|
||
public void setCouponCode(String couponCode) { | ||
this.couponCode = couponCode; | ||
} | ||
|
||
public Coupon getCoupon() { | ||
return coupon; | ||
} | ||
|
||
public void setCoupon(Coupon coupon) { | ||
this.coupon = coupon; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
integration-test-java/src/main/java/org/seasar/doma/it/temp/OrderDao.java
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,53 @@ | ||
package org.seasar.doma.it.temp; | ||
|
||
import org.seasar.doma.AssociationLinker; | ||
import org.seasar.doma.Dao; | ||
import org.seasar.doma.Select; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
@Dao | ||
public interface OrderDao { | ||
@Select(aggregateHelper = OrderHelper.class) | ||
Order findById(int id); | ||
} | ||
|
||
interface OrderHelper { | ||
|
||
@AssociationLinker(propertyPath = "orderStatus", columnPrefix = "os_") | ||
BiFunction<Order, OrderStatus, Order> orderStatus = (o,os)-> { | ||
o.setOrderStatus(os); | ||
return o; | ||
}; | ||
|
||
@AssociationLinker(propertyPath = "orderItems", columnPrefix = "oi_") | ||
BiFunction<Order, OrderItem, Order> orderItems = (o,oi)-> { | ||
o.getOrderItems().add(oi); | ||
return o; | ||
}; | ||
|
||
@AssociationLinker(propertyPath = "orderCoupons", columnPrefix = "oc_") | ||
BiFunction<Order, OrderCoupon, Order> orderCoupons = (o,oc)-> { | ||
o.getOrderCoupons().add(oc); | ||
return o; | ||
}; | ||
|
||
@AssociationLinker(propertyPath = "orderItems.item", columnPrefix = "i_") | ||
BiFunction<OrderItem, Item, OrderItem> orderItems$item = (oi,i)-> { | ||
oi.setItem(i); | ||
return oi; | ||
}; | ||
|
||
|
||
@AssociationLinker(propertyPath = "orderCoupons.coupon", columnPrefix = "cp_") | ||
BiFunction<OrderCoupon, Coupon, OrderCoupon> orderCoupon$coupon = (oc,cp)-> { | ||
oc.setCoupon(cp); | ||
return oc; | ||
}; | ||
|
||
@AssociationLinker(propertyPath = "orderItems.item.categories", columnPrefix = "ct_") | ||
BiFunction<Item, Category, Item> orderItems$item$categories = (i,c)-> { | ||
i.getCategories().add(c); | ||
return i; | ||
}; | ||
} |
Oops, something went wrong.