0

I am currently undertaking a Java project and I was wondering is it best practice to create the DAL as a class library or in an EJB? I have seen a lot of articles regarding JPA, Hibernate etc but I like to have complete control over the statements that get executed so I would prefer to write my own using JDBC.

I come from a primarily C#/.NET background and this is my first full java project so any help would be greatly received.

4

1 回答 1

1

1) EJBs primarily makes sense for services. if you already have ejb services and want to interact with db using the container provided capabilities you can still use any library like jdbc, spring jdbc, hibernate, ibatis etc for db interation within the ejb.

2) If you are building a data access layer for your services to use, then i would keep it out of ejb. It could still be used by an ejb though.

2) If you want to have more control on the statements and not use orms like hibernate, i feel spring jdbc and ibatis are some choices. ibatis allows you to change your statements without affecting your DAOs or domain objects. I am sure other orms would provide this too, but i felt ibatis more helpful.

于 2012-08-04T18:12:08.117 回答