Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

pranith rao

Greenhorn
+ Follow
since Oct 11, 2005
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 pranith rao

Thanks Jeff. I mentioned the problem before you told me. He says that adding one more table (only with one column)is more costly than redundant data. Somehow with the help of other team leaders (as the table may require additional fields in the future)I convinced him.

Thanks again,

pranith
Hi,

I have a database design problem. I do not know whether to create two or three tables. the problem is:
A terminal has one or zero placements
a placement is located in a single location but a location has many placements
for example
Terminal A (with serial number, manufacturer number etc..) is placed on first floor (placememt) located at loaction X(venue (ex:submay),street,province, city etc.)
Terminal B (with serial number, manufacturer number etc..) is placed on second floor (placememt) located at loaction X(venue (ex:submay),street,province, city etc.)
Do I have to make a seperate table for terminal, placement,location or put the placement into terminal table, or put the placement into location table
as placementt is only a single column.

My team leader has told me to put the placement in location table. But if i do in his way, when I want to edit a location I have to run through all the rows that matches the location which I have to access the table using other columns instead of the primary key (as I use hibernate).Which way is it better to design the database

thanks
I think certification helps a lot. First, it improves your command over the technology. Second, it attracts the attention of an employer. I did scjp, scwcd and scbcd. These certifications helped me to land in a job without experience and even without a technical interview
14 years ago

Originally posted by Bridget Kennedy:
I've got a situation where I'm displaying data from an object that has been lazily loaded via Hibernate. The object contains a number of collections that are shown as unexpanded links on a JSP. I'm trying to use lazy loading to avoid reading in the complete data tree, i.e. I want the detailed information contained in the collection to be fetched from the DB only if the associated link is selected.

What I want to happen is for the magic of Hibernate to recognize that the collection is part of a lazy loaded object, and then go fetch the underlying collection data.

What happens is that it does know that the collection needs to be fetched, but I get the following exception:


All my research thus far leads me to understand that lazy loading only works when you maintain a persistent Hibernate Session for all accesses to the object. Is my understanding correct? If this is the case, I would practically need to keep a single Hibernate Session throughout a servlet session. If so, can anyone point me in the direction of more words on this topic that might help me develop a strategy for maintaining a persistent Hibernate Session through multiple posts from a servlet?



Use a filter to open the session and close the session for the servlet or you can use DTO assembler pattern to create a DTO for the view layer so that lazy initialization does not effect. I use the second option

Originally posted by Kenneth A. Kousen:
This may be a simple question, but I can't seem to find the answer anywhere. I have an existing database (in MySQL). I want to generate the hbm.xml files from it. I imagine that's quite easy to do, but how do you actually go about it?

It's the opposite of a SchemaExport. Still, I imagine this is a huge area for Hibernate, since most apps already have a db schema in place.

Thanks,

Ken



Hi,

I use hibernate synchroniser. this tool even generates DAOs.

pranith

Originally posted by Paul Sturrock:
It depends on how you implement it. The recommended basic pattern is "Session per business transaction", so if one business method reads from 5 and updates 2 tables you would open the Session for the first read and close it after the last update. But there are many other valid patterns. Have a read of Hibernate site - there are plenty of useful discussions there.

No. The default is FlushMode.AUTO, which means the Session is sometimes flushed before a query is made, but you can't rely on it happening.



I agree with you. But if I close the session and try to access a lazy collection in view then it will be a problem. I think using session.flush after a query is made might be a good idea.

Thanks,

Pranith

Originally posted by Paul Sturrock:
When the Session is closed all objects in that Session (in whatever state they have) are persisted to the database. So if you open a Session, get a Person object, update its name property and call a save() method, nothing will actually happen in the database till the Session is closed (or flushed or cleared). This is why the Session is also known as the First Level Cache.



Hi paul,

Thanks for your reply. Generally anyone want to keep the session open until a request. I think by default session is autoflushed.

Thanks,

Pranith
Hi,

I am new to hibernate and I am using hibernate synchronizer 3.1. The DAO classes generated by hibernate synchronizer closes the session for most of the methods (even if I try to find an object). I am not sure the reason for closing the session. Can anyone please throw light on this?

Thanks,

pranith

[spelling fixed in title - Paul Sturrock]
[ December 08, 2005: Message edited by: Paul Sturrock ]
Hi,

Thanks for your replies. One of my friend suggested to keep the hibernate session open in the view so that lazy fetching does not effect. What do u think?

Pranith

Originally posted by Mark Spritzler:


Usually your DTOs are also the Hibernate "entities" The are JavaBeans that are Plain Old Java Onjects, then you have those objects mapped through Hibernate to your database tables. So you can use the one object for both things.

Mark



Thanks. But wont it create a problem if we access a lazy collection in an object (collection which hasnt been fetched)

Pranith
Hi,

I am working on a project and folllowing the below pattern

view(struts) ------>controller -----------> bussiness delegate -----------------> service locator + DAO (Data Access Object) ---------------------> Hibernate entity

the view uses DTO (Data Transfer Object) to display. Where do I create the DTO? Do I have to use transfer object assembler? If I have to use transfer object assembler is there any tool to create it (for eclipse) and where do I access the transfer object assembler? Please advice

Thanks,

Pranith
Hi,

Does JBoss 4.X.X support ejb 2.0 or just ejb 3.0? Please advice which is better?


Pranith
14 years ago