Francesco Pino

+ Follow
since Apr 27, 2009
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 Francesco Pino

I have to write about the following topics, and I'd like to know whether they have changed from Hibernate 3 to Hibernate 4 and Hibernate 5.
I looked at the what's new docs and it doesn't seem to me. I'm asking this because I have an old "Java Persistence with Hibernate" manual for HB 3 and I'd like to use that as the source for information.
The topics are:

• data types: entity and value types
• complex types: collections, components, composite-types...
• object lifecycle (load, delete, etc)
• Cascading
• Fetch strategy: default; hql: join; the n+1 queries problem and prefetching ("left join fetch")
• Cache: first and second level cache
• Native queries
• Hibernate, lazy loading and proxies
• Hibernate, equals and hashCode

William Brogden wrote:No you can't change the class of an existing object.

Just create a new object with the new identity and replace the old.

You are right, my question wasn't fully correct.
What I meant was how to change the TYPE of an entity during its life.
A way of describing the type of an entity is through the java Class, but I don't think it's the only one. I'm thinking to something like the State Pattern
12 years ago
I have the following hierarchy: Party is a base class, extended by Person and Corporation.
I need to change the object class of an entity at some point of its life, and I don't know what's the best way to do this.

I'm modeling the financial world, so I have that a Party can own shares of a Corporation, while only Corporation can have shareholders. Something like this:

I build the objects reading data from a source, and it can happen that at first I know only the name of a party, but I don't know wheter it is a Person or a Corporation.
But I need to create an object, so I create a generic Party. After that, it may happen that I come to know more infos, such that my Party was a Corporation. So, I need to change the class that represents that entity from Party to Corporation.
Until now, my solution was to build a new object, copying the old data into it.
But I'm not satisfied with it, and I'm wondering what's the best way, pattern or whatever else, to implement what I'd like to achieve.

I thought to the State Pattern, but I think it is best suited for other situations.
12 years ago

Ryan Beckett wrote:Java doesn't use multiple class inheritance. What would happen if both base classes had the same method? This is a problem in C++ and it is messy. Java does allow multiple interface inheritance. Similarly, the same problem can occur. But, if both base interfaces declare the same method, a compile-time error will occur when either of them is referenced.

I was talking about conceptual modeling... but, as you say, java HAS multiple inheritance, through interface inheritance. This is the same concept an is-a relationship expresses in a conceptual domain model: A is-a B, i.e. A has at least the same "interface" as B
I didn't never see an example of multiple inheritance in an UML conceptual model.
Is it possible to have two is-a relationships for one class? (i.e. like one could expect in a design model). e.g.: A is-a B and A is-a C