Importing schema from "Import Database Schema" dialog issues/suggestions (#9779)
Hello,
I have a few suggestions about generating Java classes from database schema from Hibernate Facet (Generate Persistence Mapping -> from Database Schema):
- I noticed that IDEA treats found Oracle sequences as tables, offering to generate Java class and mapping which is, I think, useless:
<class name="foo.BarSeqVO"
table="BAR_SEQ" schema="BV"/>
Java class:
public class BarSeqVO {
}
- IDEA uses "mapped" composite primary keys:
//generated PK
public class FooVOPK{
private Long key1;
private Long key2;
///getters, setters
}
//generated VO
public class FooVO{
private Long key1;
private Long key2;
///getters, setters
}
It would be convenient if the policy for generating composite-id was parametrized. As in Hibernate documentation, there are three approaches: http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-compositeid
- simple, which uses VO object itself as identifier
- mapped, (used by IDEA) which uses another class for identifier, but duplicates properties in identifier class and VO
- (recommended in Hibernate docs) identifier component, embedding composite key properties in one identifier property:
//generated PK
public class FooVOPK{
private Long key1;
private Long key2;
///getters, setters
}
//generated VO
public class FooVO{
private FooVOPK id;
//getters, setters
}
<composite-id name="id" >
<key-property name="key1"/>
<key-property name="key2"/>
</composite-id>
</class>
- could IDEA generate property/id/key-property "type" attribute (with the same value as "Mapped Type" column in the dialog)? It is optional, but if ommitted, Hibernate has to use reflection to guess.
- a checkbox (similar to "prefer primitive types") to prefer java.util.Date over java.sql.Date for date columns would be really nice.
- I noticed that char(1) columns are mapped to java.lang.Boolean by default. I think java.lang.Character/java.lang.String would be better
请先登录再写评论。
Hello.
I could not reproduce the last issue in build 9795. For Oracle column declared as "char2 char(1)" the java.lang.String is suggested.
Regarding the other problems, I think, you are welcome to create 4 JIRA issues: http://www.jetbrains.net/jira/browse/IDEA
Alexander.