avihai marchiano

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

Recent posts by avihai marchiano

I have manager (1:m) ---> employee

I set second level cache on the manager and on the employee and the relation is eager.

how ever load manager go to the second level cache but when iterate on employes go to the DB- any idea?
Hey,

I want my dao to get interface of the entity and not the entity. Like this:

public void save(ICustomer customer){
session.save("CustomerEntity",customer);
}

If i pass instance of CustomerEntity its ok, how ever if i pass another implemantation of ICustomer (not mapped entity) i fail.The implematation that i send has the same structre like CustomerEntity .

Thank you
Hey,

i will be happy to your opinions regarding - working detached in the service layer/ business layer.

For my opinion work attached in the servie layeris not a good practice since in this way we bypass the dao layer, which break the encapsulation and resposibility rule of each layer.

I dont love the attach idea, for my option save to the DB need to have single point of responsibility.

Additional point:
Since we begin the transaction in the service layer the objects that will returned from the DAO are in attached mode, so if we want to work detach we have several options:
1. call to evict or clear - not good , because we lose the first level cache advantage.
2. copy them to new objects - not so simple, because they have proxy ...
3. use in solutions like giled.
4. deepl clone by serialize

Do you have more solutions?

a link to similar topic:
http://www.theserverside.com/news/thread.tss?thread_id=40581
Thank you

I am also looking for an idea for needed tool or utility and create an open-source for it.
Or join to an existing one.

If someone has an idea for utility that can help and save time, i will be glad to hear.

Thank you
13 years ago
Hey,

I have entity type category and another entity type - logisitchierarchy.
From the business prespecive they have nothing in common.
From the structre prespective - they both have a tree (hierarchy structre - parent - childs) - so they share "structre functionality" like calculate path , get root and etc.


if for each i write the structre and they not share the same base, fix for the base structre - for example you discover that the best way to model tree is with addtional column for calculate-path..., will required to fix it in all "trees structre" in the application.

in addtional base class for all make it easier to share structre functionalty.

what is your opinion - does common structre (a one that required complex functuionality) are a good reason to inherit from the same class?
YEP -the query is like you wrote it.
How ever this is not change the question.
This cause a serioes performance issue.
One query instead on join between all entities loaded execute with select for each root entity reference.
Hey,

I have Person->Address->*Contacts (collection of elements)

(in my model i have heirarchy with more levels).

i use the following query:
from Person person left join fetch Address address left join fetch address.contacts

in the SQL that hibernate generate i notice that it excute select for each person references, so if i load 10 persons it will run 10 selects for address + 10 selects for contacts instead of load them in a join.

Any idea how to start debug this?

Thank you
Thanks a lot for your answer.

I implement my own proxy cleaner (in less than 50 rows).
My ptoxy cleaner in case of onetoone proxy initiate this reference and set only the id (in one to one reference you can get the id from proxy without the need to init it), so when the client send me object i see if its only "light entity" and in case it light i dont cascade it.

The problem is with collections proxy. i dont want to send them as null, so i think i will create my own collection and in case of proxy collection i will mark it with my own collection.


Thank you
Hey,

The model is a collection of entities with relations between them.

Entity 1 has reference to other entities which have reference to other entities and ...

for example A->B->c->(1:m)D

In some case entity in the model is a graph of objects that has more than 10 relations level.

When you update an entity , you dont expect that the use will give you the complete relations.

now, say that the user send you A for update and b attribute (ref to B) is null- so in this case you will nulify the relation:
solution1: the user must supply ref to B with atleast the B id (maybee he change the ID).
there are few more solution that i have . I will be happy to hear yours.

My question is how to deal with list reference. suppose A has List.
The client cannot send listB as null, but we dont expect for load list only in order to represent the ID references like we did in 1:1.

In hibernate when you load A without his references it set proxy on the references ,this help to know (and load) if this reference changed by the client and need to be update or the client didnt touch it at all and want to update only entity A.

it can be an ugly solution to required from the client to set some proxies or any other alternative on the uncahnged reference?

wait to here your ideas.

Thank you
try to close the session and than call the u.getPassword
Hey,

I want to write a diff instance class.
The DiffInstance will get two instances of the same class and will return a collection of difference between the instance.

This is done because there are a lot of services that triger by changes in the model.
For example - audit need the diff between previoues state to new state, businees trigers that are intresting in changes in the model state and etc.
So i plan to get the new state in the fron service compare it to the old state and sent the diff to any registered service (like audit).

1. are you agree with me that its better to take the diff in central place and avoid compute the diff in each of the registered services?

2. what do you think will be a good structre for the diff result? my first thought was something like jxpath (or any other navigation expression like -http://java-source.net/open-source/expression-languages ), but i have two problems with this:
a. sets
b. what if one of this tools need to get the field for annotation info?

any ideas?
13 years ago
Hey,

working with JPA above hibernate impl. I map my enums by using user-type follow the good practice to store a persistence key to the enum and not the ordinal (which can be changed).

Now, i have a problem to query on the enum field. it seems that hibernate dont execute the user type convert on the name-query.

Any idea?
Thank you , but this is not the question.


The question is how to detach hibernat entities.

you have layer AAA - > call layer BBB - > call layer CCC - > call DAO.

i dont want that the dao will return attach objects.

This break layering, i want to detach the hibernate objects before the DAO return them to the caller layer.

You can do this by:
clone the object
limit the dao transaction scope.

but i dont love any of the idea above.
My quesion is - if you have any idea how to detach the hibernate objects?
Sorry for not beeing clear.
I will try to be clear now.
Thank you for your answer.

I am not questioning about when the j2EE transaction begin.

I will be more specific.
Jboss + JPA (hibernate).

When the trnsaction begin in the DB?
is it when the entitymanager injected in the first time during the j2ee transaction scope?
is it after the first query or after the first update?


Thank you
14 years ago