Added a method
/** * Return true if a prefix should be used building a foreign key name. * <p> * This by default is true and this works well when the primary key column * names are simply "ID". In this case a prefix (such as "ORDER" and * "CUSTOMER" etc) is added to the foreign key column producing "ORDER_ID" * and "CUSTOMER_ID". * </p> * <p> * This should return false when your primary key columns are the same as * the foreign key columns. For example, when the primary key columns are * "ORDER_ID", "CUST_ID" etc ... and they are the same as the foreign key * column names. * </p> */ public boolean isUseForeignKeyPrefix();
You can set useForeignKeyPrefix to false using ebean.properties
ebean.namingConvention.useForeignKeyPrefix=false
@Entity @Table(name="o_order") public class Order { @Id @Column(name="ord_id") Integer id; String description; @ManyToOne Customer customer; @OneToMany List<OrderDetail> details; ... @Entity @Table(name="o_customer") public class Customer { @Id @Column(name="cust_id") Integer id;
... with useForeignKeyPrefix=false the foreign key column is "cust_id"
... and note the fk column of cust_id ... is the same as the pk for the customer table.
select o.ord_id c0, o.description c1, o.cust_id c2 from o_order o
Fixed in HEAD.