Emanuel Kadziela

Ranch Hand
+ Follow
since Mar 24, 2005
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Emanuel Kadziela

Have you tried closing the stream?
9 years ago
A Google search of "choosing the right hibernate inheritance strategy" yields this result in around 10th place: http://what-when-how.com/hibernate/inheritance-and-custom-types-hibernate/, an article with a great wealth of information on pros and cons of each strategy, details on their implementations and configurations, and other related advice and information.
Whenever the HibernateTemplate calls "getSession()" it eventually calls "releaseSession()". I'm pretty sure you have to follow the same pattern or you will see the kind of behavior you are seeing.
Why don't you read this hibernate documentation on inheritance and the various strategies first, and then ask more specific questions if you don't understand the finer details.
If you are indeed not closing transactions, then you didn't post enough information. How is hibernate setup? What is the reference to "dao" in this line: "dao.getSession().get(ReflectionUtils.getSuperClassGenricType(getClass()), id);" pointing to? What "dao"? How does that "dao" implement "getSession()"?
Load the properties - that holds them in memory. If you want to update any of them, read what is there first, compare, update, and replace. Store whenever necessary (if you worry about crashes and stuff, store every time you make an update, otherwise, store periodically or just at the end of a session).

The alternative way is to use plain old file io with the option to append instead of overwrite. The problem there, is that you will end up with multiple properties with the same names (which is worse).
11 years ago
String.split() takes a regular expression as input, not a string. In regular expressions, dots are not literal - they have special meaning. If you really want to split on a dot, you have to escape it.
11 years ago
Load the properties first, then update them, and then save them.
11 years ago
I'm not sure if this is correct, but it sounds like a rounding issue with doubles. Try to replace the exact "equals" comparison with something more tolerant, like:

11 years ago
I don't know much about EJBs, but I do know that the ORM layer needs to be aware of the relationships between entities corresponding to the relationships in the database. Managing associations is one of its main advantages.

Relationships in your entities and ORM mappings can be one-directional or bi-directional. No one says that a User object needs to be aware of all its comment objects. The UserComment can have a one-directional reference to the User mirroring the underlying foreign key reference, but the User can be completely unaware of Comments or UserComments. That's one of the reasons why fetching one entity does not bring the whole database with it. Lazy loading is another.

If a comment is just a comment and cheese is just cheese, why do you want to put your comments in different tables? If you don't care where the comment came from, just as you don't care which pizza your cheese ended up on, then just put them in one table. But as soon as you start caring about which pizza got which slice of cheese, or who made what comment, and you start making that differentiation in the database, you need to reflect it in your ORM mappings, or modify the ORM code itself.
You're focused on the name attribute, but have you thought about the foreign key mappings? Each comment relates to a specific entity owning the comment, right? This means if you ever want to find comments for any specific entity, you need a foreign key reference to the owning entity, and each comment type will have a foreign key to a different entity (UserComment points to User, EmployeeComment points to Employee, etc.). All of these foreign keys have to be mapped.

I don't believe there is any way to avoid having separate mappings for each Comment. It would be advisable to use the inheritance mappings and have the Comment class be a superclass of all specific comment classes, but I don't see any way of avoiding separate mappings for each specific Comment entity without significantly rewriting or customizing the ORM code itself.
You can also try this URL: /RestSimpleApp/orders/foo?testid=1
11 years ago
Your code right now:

URL you're trying: /RestSimpleApp/orders/1

My suggestion:

URL to try: /RestSimpleApp/orders/foo
11 years ago
As far as I know there is no way to do what you suggest. One Entity = one table, except for special cases like inheritance scenarios, which you indicated you are not interested in.

Perhaps if you describe your actual requirements in more detail, we can suggest an appropriate design/solution.
Have you tried to not use a variable in your @Path declaration? Like @Path("foo") and then hit the url : /RestSimpleApp/orders/foo. If that works, it means you have set up everything correctly, and you either cannot use a parameter in the @Path declaration or you are not doing it correctly.
11 years ago