|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2007-12-14
针对你的需求,我觉的你可以采用数据库设计方式。
|
|
| 返回顶楼 | |
|
时间:2007-12-14
基于数据库设计和基于领域模型设计,你真的没有必要把它分得那么清,楼主的意思可能是先有表呢还是先有对象,不管你是先建表还是后建表,数据表都是当你分析了业务逻辑后得来的,其实你已经不知不觉从领域模型开始了。
正如抛出异常的爱所言:
领域不是目的,目的是更好的抽象业务。
|
|
| 返回顶楼 | |
|
时间:2007-12-15
使用Hibernate时,应该先设计领域模型,从领域模型生成数据库表。
通过下列代码可以自动生成数据库表:
Configuration config =
AnnotationConfiguration().configure("/hibernate.cfg.xml");
SchemaExport schemaExport = new SchemaExport(config);
// script, export, justDrop, justCreate
schemaExport.execute(false, true, false, true);
然后再检查生成的数据库表,必要时进行优化(如添加索引等)。 |
|
| 返回顶楼 | |
|
时间:2007-12-17
谢谢大家的讨论,最近偶然看到一本外文书,作者是参与Hibernate设计的开发人员,书中也对这设计的方式进行了讨论,作者就认为没有一成不变的设计方式,要根据具体的情况来做具体的设计方式,归纳为三种
1.POJO-Driven Approach In the POJO-driven approach you start with an object/domain model, and using JSR-220 annotation or Javadoc metadata comments, you define how each field in a class maps to a database column. At runtime, Hibernate uses the annotations to dynamically create the mappings. 这种方法适用于数据模型还没创建和设计或者不明确的新应用程序 2.Data Model–Driven Approach In the model-driven approach you start with a database schema for the chosen database system, and using a tool like Middlegen or Hibernate Synchronizer, you generate mappings and POJOs for each table being mapped. This approach provides a fast start-up time for development。 这种适合已建立明确的数据库或者数据模型的web开发,并能快速的开发。 但也指出使用这种设计的方式会造成域模型的semantic(语义)不够丰富,达不到你原先设想的那样。 3. 作者自己推荐的是一种是第三种方式,称为HBM-Driven Approach。 The two previous approaches, taking either a domain-model or data-model approach, typically result in HBM mappings that are not quite complete. Every time I use either of the approaches above in a moderately complex application, I find myself fine-tuning the HBM files to either get more accurate POJOs (in the data-driven approach) or more efficient, manageable database schema (in the POJO-driven approach). The third approach suggested here takes the stand that object-relational mapping is an inescapable, necessary evil that should be taken into consideration early and in a head-first fashion in the development of your application.By creating detailed, accurate HBM files you will end up with both a domain model and a database schema that meets your application needs and ensures the longevity of the data |
|
| 返回顶楼 | |
|
时间:2007-12-17
个人感觉像是对前两种方法的一种优化或者折中
|
|
| 返回顶楼 | |
|
时间:2007-12-17
引用 最近偶然看到一本外文书,
请问是那本书?能给出书名吗? |
|
| 返回顶楼 | |
|
时间:2007-12-18
是pro hibernate系列的书
|
|
| 返回顶楼 | |
|
时间:2008-01-09
先设计实体,由实体生成表 吧。
|
|
| 返回顶楼 | |
|
时间:2008-04-12
其实领域模型中的实体和实体关系模型中的实体能有多大区别呢?
领域中有些对象是要建模为每个都是不同的,那就建成实体咯。 然后实体和实体之间有关系,就有了实体关系模型中的关系 就有了领域模型中的关联关系。 对象中有继承关系,实体关系模型没有,但有很多策略可以进行映射[Fowler02] 然后对象建模-->实体关系模型 |
|
| 返回顶楼 | |








