File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes 3 questions regarding Hibernate with Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "3 questions regarding Hibernate with Swing" Watch "3 questions regarding Hibernate with Swing" New topic
Author

3 questions regarding Hibernate with Swing

Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 501

I am working on application...explanation you can see in swing & jdbc section.
Simple & short explanation:- Swing application contain Array of Jpanels in Jscrollpane which resides in JFrame...Array of jpanel have facility of Drag & drop any where within Jscrollpane with avoiding most of possible problems. Old & new position x,y axis of jpanels stores in mysql table.
Currently i done 9 panels but in future if i succeed then 100 then 1000 & then 10000 that much i will increse it.
Currently program is standalone desktop application(non-managed environment)...but if possible then i try to implement client-server architect with managed environment ...

but now i am thinking to do it with hibernate...
Question asked when i post previously regarding persistence of jpanels positions...why you want to store x,y axis in db...why not use serialization...
After research on it..i got answer which i think right for me in book(Hibernate in Action by Cheristian Bauer & Gavin King)
In that book says...

Unfortunately, a serialized
graph of interconnected objects can only be accessed as a whole; it’s impossible to
retrieve any data from the stream without deserializing the entire stream. Thus, the
resulting byte-stream must be considered unsuitable for arbitrary search or aggregation.
It isn’t even possible to access or update a single object or subgraph independently.
Loading and overwriting an entire object graph in each transaction is
no option for systems designed to support high concurrency.
Clearly, given current technology, serialization is inadequate as a persistence
mechanism for high concurrency web and enterprise applications. It has a particular
niche as a suitable persistence mechanism for desktop applications.

If we consider as my program only use on desktop application with less number of array then serialization can be thinkable...
But if we try to imagine about it, if it use on client-server architect then...

I study little bit about hibernate with many books/forum/Wikipedia & still learning...right now i can just fetch data from table by hibernate... now trying complete CRUD queries...
My question is by many forums i will get examples regarding this..but
question 1: In real world should my idea is ok or not?
question 2:- Any where i got clue about any one done this type of application..(not want source code but want to know that yes xyz done & used or no no one tried this before...etc etc...)
question 3:- What & how could be problem face if i try to create this type of program...


Millions saw the apple fall, but Newton asked why.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Your quote in your signature says it all. I don't understand what you are asking.

Are you asking where should you store your panel locations? Why not just in memory in a Map or some other Collection. If it has to be persisted, then where do you want to store it, in a database?, then you can, create a table and store the data there. You can use Hibernate to do your CRUD operations on the table. You can use a simple database like Hypersonic or Derby.

But the fact that you are using Swing has no bearing on that problem.

Hope that is what you were looking for.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 501

Thanks Mark Spritzler,
What a great pleasure...
Your quote in your signature says it all. I don't understand what you are asking.

I surprise that i repeatedly failed to explain my question in this forum's various sections.
As i write before...
I am working on application...explanation you can see in swing & jdbc section.

References regarding this...(I explain lot of...anyone can observe how i go further by way which shown to me by this forum...
1. Swing
2. JDBC
3. JDBC again
4. Java in General

This application is because its concept never discussed or tried on any forum...
People always try to implement flawless Drag & drop facility to Components within Container, but i not found any example of container has facility of drag & drop within container...
Currently All this is only thought not actual any big project...but if i succeed to do this then surely i get chance to implement to big project as patch of it or something like that...

I always trying to be simple & basic code...but as i go further i got various new topics information, when i read those & tried it,then i get more complex issues...& chain going on...

First i tried basic swing program(I know only basic java with jdbc & little bit sql)... 1Frame which contain 1 jpanel which fits to that frame, in that jpanel there was 2 small jpanels...& i tried them to be implement drag & drop functionality...As i not know serialization, i tried with what i know.

When i get little bit success, i tried with Array of jpanels, then Jscrollpane,jtabbedpane as container of those small jpanels...
All type i can done properly but only one thing i cannot do or understand....( i asked it in 1st reference's last post)
When i run above code..then only last object of array (if array of 9 then 8th) avoid overlapping when other try to overlap on it....
Same time when smaller Array value jpanel dragged on higher value jpanel then it goes behind not upside.(eg if i drag 0th panel on 1st panel from array of 9, then it move from upside of 1st panel...
but when i drag any other panel to 0th panel then it goes behind 0th panel...i dont no why...& also not know how to avid it...all jpanels should move upside of other panels when they drag here & there.

I know that issue is purely siwng & logic...i will definitely solve it...if anyone expert it swing please help me...( i know i am asking wrong location..here some one looking at my efforts...efforts never wastes)

Now question how & why i shift to hibernate instead of using serialization or something different technique...
As in JDBC section people suggest me about serialization & same time i got info about persistence, then by google i got huge info about hibernate.
& eg if i want to write splitting of 100 in various way..then intelligent/smart people do 50+50, but if i have to do so then its not wrong that 10+10+10+10+10+10+10+10+10+10.
Same way it might be easy to do by serialization or something different techniques to store jpanels co-ordinates...but database will not stop me to store it in to tables.

By reading your reply i think, i got answer of question 1 only...
What about 2 & 3?
I hope now my view is clear...if i wrong then dont hesitate to tell me what is right!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Again, I don't understand what the problem is. It doesn't matter that you want drag and drop in Swing. Do you have a specific question that you are having a problem with? I cannot see what that would be in your post. Just break it down to the simplest part and we can work on it little by little.

Do you have an JPA/ORM Hibernate only question. Forget about Swing, for ORM that is irrelevant.

Do you have a Swing question? Then don't bring up JPA/ORM because for Swing that is irrelevant.

We don't need to know high level about what you want to create in your application, unless that alone is your question.

I can only help one question at a time.

So please try to just break it into small questions.

Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

There should be no mention of Swing stuff here in the ORM forum. But Drag and Drop is extremely common in Swing and has been done many times over.

Mark
Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 501

Again, I don't understand what the problem is. It doesn't matter that you want drag and drop in Swing. Do you have a specific question that you are having a problem with? I cannot see what that would be in your post. Just break it down to the simplest part and we can work on it little by little.


Simplest question is using swing & hibernate, mysql if i create program which has functionality of drag & drop facility to jpanels within jpanels, then what will be problem occurs?
Currently i write program which stores x,y co-ordinates of jpanels in mysql by hibernate when i drag it & drop it any location within jpanel...
From now i will try to fetch stored values & try to setlocation of jpanels by them.

i ask separate question in this forum..how to use println for reusltlist in hibernate?

In this topic i just want to know theoretical problems possibility discussion...practically i will ask separate small problems...
Now i think its more simplest...
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

So then your question is not an ORM question and therefore should be in Java In General.

As far as an answer to that question, it is more philosophical than technical. You can choose to store it anywhere. Each has pros and cons. But the pros and cons are because of your choices not because of what you are doing. The question is where do you want to store your state to be persistent. A database is as good a place as any. But if it is a small amount of data, maybe you just save it with serialization or a flat file. That is completely up to you. Meaning they all work.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 3 questions regarding Hibernate with Swing