jim mcnamara

Ranch Hand
+ Follow
since Jun 13, 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
1
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 jim mcnamara

HI-

thanks for the cool tips!

Have a cool night,
jim
Hi-

No, I didn't call a folder by that name. It was a package. Sorry.

The package is in the source folder and it is like org.apache.derby.ui.test.ClassName.

Thanks everyone for helping. With your encouragement, I have a hello world type project.

The Hibernate query result is now working (except I have to edit the pojo to handle the strings differently)!

One of the buggers that got me was the underscores in the table names for i.e. City_Name.
I got rid of those as I didn't need to have all the fields from the table mapped.

Also, in the sql error window I didn't know how to expand the error listed to read the stack trace until now.

This makes me very HAPPY. Hopefully I can practice a different types of mappings next.

THANKS AGAIN!


HI-

I thought I'd outline my project folder set up too...
I hope seeing this helps. THANKS!

the error in the hibernate query result is:

org.hibernate.hql.ast.QuerySyntaxException: Cities is not mapped [from Cities]

thanks
oops... sorry about the code tags- THANKS!
Hi-

I can't figure out why the class is not mapped! Maybe a fresh set of eyes and/or ideas can help. Thanks for any assistance.
I haven't looked at Java in a long time.

I tried with both org.apache.derby.ui.test.Cities and without the package prefixes.

Here is my hbm.xml .java .cfg.xml



Hi Hitendra-

I put up some sample code I fooled with a little tonight. I did a native SQL join. The code is on my site. I think this way is the quickest. All you need are 2 pojos, the mappings, and the config file and if you have db experience, it is really easy to write the sql.

The joins you are talking about may be the collection mappings. I also have an example of that on my site, my first "one to many" mapping. If you need finer grain control than mapping a collection, like a set, you can use HQL or write the native query.

You can email me if you like, and I will try to send my config files or whatever you need to get going. I could probably add a link for project files for download.

My site is at 3rdshiftcoder

My email is thirdshiftcoder@gmail.com.

I am just a keyboard specialist that likes to code as a hobby, and I have learned to keep my attitude in check. Helen Borrie, who writes Firebird books, described herself, among other things, as the bottle washer for the Firebird Foundation. That teaches me a thing or two about not worrying about a title.

I like the Hibernate without JPA. I don't have a manager worrying over my shoulder about switching ORM provider, so thus, no need to worry about the standard JPA.

I might be able to help with m2 plug-in with Maven if you need help. I am learning that with a little success with the help of the forum. I only know a subset of it though.

I don't know if you use Eclipse.

Well, whatever your decision, that is cool. I am just learning too.

Having said all that, I find the tutorialspoint site for Hibernate is really good. It is maybe all you need anyway. Also, the new Hibernate book comes out sometime around March at Amazon.com.

good luck,
jim (hobby coder)



Hi-

I did a little more research. I found that after the heap was increased with my hibernate code, successive calls to output the hello world SWT app and another shell did not add much at all to the heap size. So, while it didn't give all the memory back, it is good to know that it doesn't run wild and keep increasing the heap memory much when I launch other shells. It was reusing memory!

It seems that one mapping file .hbm.xml doesn't take up too much with hibernate. My reasoning would then be that each time the table is queried with createQuery, the memory would be somewhat constant as each mapping file would take relatively the same memory. This of course, if you don't load really large tables. I heard one person say their size grew to 475 mb of ram because they had a lot of mappings. That seems to blow a whole in my theory of each mapping file as relatively constant, not adding much more to the initial heap size after the first run. Since I will do small apps, that shouldn't be a problem.

I will keep checking on this later on as I write more code. It seems like it will be okay.

Very cool,
thanks

hi-

In the following two code samples, I use Hibernate and then pass the results as a ArrayList to a GUI app. The problem is as I have watched is that it doesn't release the Hibernate memory until the GUI is closed. I find it interesting that "hello world" in SWT without Hibernate is only 13,000 k of java heap memory, and my current GUI app is not much more complicated, but I can't get the computer to release the memory, until I close my GUI app. If I make it Hibernate only with no GUI the memory spikes to about 48,000k, and when the program is done running, it takes 0 memory in the taskmanager in Windows 7. If I run the GUI SWT app, memory gets as high as 55,000 k for that little app which shouldn't be so high, if the memory is released from Hibernate.

Any ideas how I can fix it, or am I stuck with it? I worked kind of hard trying to come up with this code so far and to diagnose. Maybe I can reclaim the memory somehow in my code like setting the initial heap size again right from within my code. As I understand, garbage collection reclaims heap size. GC happens when I close the SWT app. Do you find similar issues? Please help me fix it. THANKS


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
>
Hi Ulf-

I just had an idea. I ran just a simple hello world application with SWT code and no extra java code. It was 13,000 k in the task manager. I noticed its initial heap size was less than 32 mb.
I am going to run a test with hibernate and no SWT and launch that to see what the jvm does kind of like the hello world test for hibernate.

jvm threads on forum


from the link above:
"When you start multiple Java programs on your computer, each of those programs will run in a separate process, with a separate JVM (instance). "

Thanks for helping. No need to post anymore on this topic. Post closed and solved.

thanks




thanks
Hi Ulf-

Thanks for writing. Each process is in the windows task manager is listed like this:

java.exe 30,000k
javaw.exe 28,744 k


I meant MB but they list in the task manager as ending in 3 extra 000 like 30,000,000 instead of writing 30 MB. It is kind of like when you read financials and you have to add whatever zeros you need, so the report makes sense. Sorry I wasn't more clear.

Java is tricky for certain things. I will go to the other forums and ask in brevity how much SWT tacks on and how much hibernate tacks on. I am going to strip the thread code out of my little GUI app because I need to experiment with threads more before trying to use it.

I am just trying to obtain a general idea, and you definitely helped. You said the JVM normally allocates 32 MB. That helps and is a good start. I am going to read a bit more before posting at Hibernate and SWT forums.

thanks!




"Memory Requirements

The following tables list the minimum memory requirements for Windows 64-bit operating systems:

Note: The minimum physical RAM is required to run graphically based applications. More RAM is recommended for applets running within a browser using the Java Plug-in. Running with less memory may cause disk swapping, which has a severe effect on performance. Very large programs may require more RAM for adequate performance."

I am using 69k and 49k for java.exe including the apache derby db server process in those numbers. It is hard to believe, but according to this, am I not doing that badly??

I use SWT, apache derby, hibernate, java for my simple GUI application and package my start up jar with maven.

Please respond with a quick sentence like "it is okay - that sounds normal." The way I interpret it is that it goes up from the baseline of 128k or so, depending on the size of your application in Win 7. It seems so huge. I keep thinking I did something wrong. The people at work want to know if my application is taking up too much memory. I don't mind if that is normal, as I have lots of ram on my machine.

I have to catch some sleep. If my app is okay with memory use, Id like to consider continued use of java! I want to get better at hibernate.
THANKS!
HI-

I launch the app with java -jar myjar.jar com.thirdshiftcoder.derbyApp.MapDemo.

My hobby site is here my web site

That way you can see the picture of the small application.

thanks
HI-

My app in the task manager is using 60k java, 50k my little application, and 22k (derby db). I am trying to use threads so that it doesn't start its own jvm. Should that help?
I don't think my application should take up 50 k.

The app runs but I haven't figured out the threads part to it.

Please assist if it is something minor I am not doing right but if it is a real mess just say so. Thanks for any assistance or advice. I will stay up a while in case someone is around. I
am going to make a quick pizza run and I will be back. I will be up for another hour or two at least GMT - 5. THANKS

Here is the code:

Hi- E. Armitage -

Thanks for all your help E. Your the best! I am learning to deploy now and from your tips figuring out where m2 plug-in and maven fit in. It is very cool to use. I really did like fatjar with onejar but fatjar was always so slow. I think this way is faster. I like how you can select from more than one repository and can also install 3rd party jars from the command line to the repository for those ones you need that aren't available in the repository. I did that with something I couldn't find elsewhere after using 2 repositories. I believe it was a jpa jar for hibernate. JPA was a requirement for deploying my hibernate app, but I couldn't find the right jar in the maven of jboss repo.

I am so glad I stuck it out. There was one night that nothing went right, and a few expletives were abound, but then I put on my rally cap.

Very cool.

thanks!
10 years ago