我觉得技术就是一种道路。我在走的时间看了路上的风景,然后和其它风景进行相互比较,得到一种相对通彻的感觉。我又看到了其它的风景,然后我看到的又是受到以前的影响和关联的感觉,觉得万事物皆关联,具体的一条道路究竟是什么层面和通向什么将来,倒不是很重要了。
Hibernate入门很简单,看看就会用,但是功能非常非常强大,扩展性超强,有点学无止境的感觉。
那个Middlegen生出来的代码比较烂,要修改不少
你的话让我误会了,数据库要设计连接表啊,Middlegen本来就不会有机会处理多对多关系
我还以为有别的办法处理多对多的关系
>
> Warner has been using Torque for a while, rated Hibernate a bit lower
> because the docs were a bit sketchier. Castor rated a bit lower for the
> same reason.
>
>
> ---+ Torque
>
> + showed the database XML schema descriptor file
> + setup database tables and fields, hand generated
> + can also create relations between tables
> + generates SQL from the xml config file
> + generates different sql for different database
> + config file data types are 'Torque' types, not DB dependant
> + noted that there is an Ant task that can be run to create all the
> DB tables from the gen'd SQL, but said he hasn't tried it yet.
> + showed the generated classes
> + looks like a "BaseFoo" object/peer & "Foo" object/peer
> + showed that it created a Group.getUsers() method that will return
> a list of related objects (i.e. Users in the Group)
>
> + Torque Properties
> + uses log4j
> + properties seem to hint that multiple DB's could be used, but not
> sure if it's really working/stable/non-vapour
>
> + Retrieving records
> + Peer.retrieveByPK(PrimaryKey) : calls are made directly to the
> peer
> Q: If calls are made to the "Generated" Peer directly...
> subclassing concerns?
>
> + built-in retrieval by ID, or by Criteria object
> + Criteria are bundles of filter objects
> + Related objects can be retrieved by calling the Object ex.
> user.getRoles()
> + Q: Will it always return a List?
> + A: Looks like it's a List always, perhaps of only 1 object...
> It might be a configuration option for the Schema config that we don't
> know about.
>
> + Persist an object
> + object.save() handles inesrts/updates
> + Delete an object
> + BaseGroupPeer.delete(Group) : kind of odd since the object knows
> about it's peer, not sure why the BasePeer needs to be called... FollowUp
>
> + Uses DB Conn pooling - not sure which one (perhaps Commons Pooling)
>
> + Object Cacheing: maybe NOT (FollowUp)
>
>
> ---+ Hibernate
>
> + can generate code and mapping from existing db, or xdoclet, or can
> tweak the gen'd mappings, and/or export schema from java classes
> + docs seem to be sketchy
> + generates an XML doc
> + all persistent classes must implement Serializable... maybe...
> FollowUp
> + noted: only had a windows.bat file not sh script
> + showed props file
> + seemed tiny compared to torque
> + Uses DB Conn pooling - not sure which one
> + Object Cacheing: maybe
> + Doesn't generate Peer classes, handles the persistence internally
> + Retrieve an object
> + uses it's own OQL-like query langauge
> + call into a Hibernate "Session" - not sure if embodies a
> transaction and/or handles multiple transactions...or any transactions
> + Code to run
> + create a 'Datastore' and load in the mapping for the classes you
> want to persist
> + potentially can specify the mappings in one config file instead
> of smaller individual files
> + create a SessionFactory from the Datastore
> + Not sure how to retrieve related records to an object
> + also, not sure how to have related objects be updated
> automagically
> + Warner hasn't had a chance to figure this out yet.
> + Persist an object
> + call Session.save(object)
> + Q: Can it persist Lists of objects?
> + A: Not sure if any of them do this. FollowUp
> + Q: Do any of them use Prepared Statements to speed up persisting
> lots of objects.
> + A: Not sure about that. FollowUp
> + Q: Do any of them do batch inserts?
> + A: FollowUp
> + Delete - session.delete(obj) and it goes bye bye
>
> + Showed the hibernate mapping generation tool (java app)
> + seemed to be able to do different key types on a per table basis,
> but we're not sure
>
> ---+ Castor
> + Background - started as a mapping from Java to XML
> + noted how the 'jdo' for objects was tacked on, but didn't seem to
> get as much attention as the XML mapping.
> + Mapping
> + looked at a tool "jdomapper" for creating the object maps
> + many options there...but not real clear
> + 3rd party tool, not shipped with Castor
> + Q: noticed on the tool "Lazy" - so we assume Castor supports
> lazy loading of child objects, but need to FollowUp
> + Castor supports xDoclet tags
> + Retrieving Objects
> + Uses it's own OQL, or can use SQL directly
> + Warner didn't see a convenience method for pulling in a single
> object, showed a SQL statement for specifying an object id. Yuck!
> FollowUp
> + pull in related objects - not sure how yet FollowUp
> + discussion around maybe "OQL does this out of the box?"
> + we really don't know... did find in the Castor docs
> (doc/oql.html#OQL-FAQ) that the OQL parser will be updated in phases "The
> Castor OQL implementation is currently in phase 3 of development. NOTE:
> This documentation is not yet finished"
> + Persisting objects
> + looks like Castor does have transaction mgt, and makes changes
> through a "Database" type object.
> + Warner noted that he believes Castor-JDO isn't being maintained
> directly
> + Drew: noted that he felt the JDK 1.4 built-in XML serialization was
> better than Castor
> + TLC: Notes from the docs (\castor-0.9.4.1\doc\pooling.html) -
> there's no database pooling built in
>
> Q: What's good about each one?
> A: Hibernate - looks like a good arch (or did he say this about
> Torque?)
> A: Castor - dicey, lack of tools
> A: Torque -
>
> Q: What really sucks about each one?
> A: Torque: would like to see less generated code (like Hibernate)
> A: Hibernate: more and better docs
> A: Castor: better tools to help get up and running
>
> Q: Any impressions on the user numbers?
> A: Torque: Warner has been on the list, so estimates 99.9% Turbine
> users, but not many independant
> A: Hibernate: thinks it's gaining some popularity, but only has a
> developers list, no users list, just a users forum
> A: Castor: supposes a very small JDO user base versus the XML base
>
>
> TJDO - another open source
> OJB - "danger Will Robinson"
Hibernate是JDBC和实体Bean之间的一种选择,一种技术能够被重量级应用,是否支持集群是很重要的标准。
DAO和Hibernate都是无法支持集群的,所以它们直接使用只能限定在单个服务器之中,如果需要集群,可以自己使用Javagroups这样的技术来做,但是我想不会有人对某个技术这么执著的。
DAO和Hibernate都是无法支持集群吗??小弟不懂,请高手证实!前面不说说到hibernate最大的单子有10亿美金吗?