||Hibernate Your Data|
|Subject:||avoiding setter methods|
i'm new to hibernate and this article gave me a great introduction to it.
i have a question: isn't it dangerous to have setter methods for all properties in the "business objects"?
for example, class OrderItem in the example presented in this article has a constructor that accepts an Order, a Product and an amount of products. the constructor decreases the Product's stock availability by the given amount, and sets the price of the order item accordingly. after an order item is created, you could, for some reason, call its "setAmount()" method. since this method doesn't adjust item's price and the product's stock availability, you could easily get get into serius trouble since the amount of products on the stock and the price of the item would be wrong.
i presume these methods are here becouse hibernate needs them to create objects load data from a database into them, so they are not meant to be used explicitly...
i'd like to know if there's an easy way to avoid these methods in the "business objects"? (other than "being careful and not use them int this way" :) )
1 to 1 of 1
avoiding setter methods
2004-01-19 15:00:51 epbernard [View]
1 to 1 of 1