Kamil Kuchta

Greenhorn
+ Follow
since Mar 09, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Kamil Kuchta

I have problem to create some HQL query.
This is my object model. Hotel has list of Image.


Standard SQL in this case is easy:

But how to create HQL?
Answer:
I have to use SimpleJdbcTemplate to call stored postgresql procedure. It must be SimpleJdbcTemplate because my test class extends AbstractTransactionalJUnit4SpringContextTests which has simpleJdbcTemplate.

I found this:

http://static.springsource.org/spring/docs/2.0.x/reference/jdbc.html#jdbc-JdbcTemplate-examples
but

doesn't work. Maybe is some detail wrong? Somewhere I met call package.my_function(?) but my function is in no package.

https://coderanch.com/t/60690/oa/Calling-Stored-Procedure-jdbcTemplate
doesn't work with simpleJdbcTemplate.
I would ask for using resources especially images.doesn't work.

The only solution which I know is to store images in package com.my.app.widgets.resources and use
<ui:image field='pic' src='resources/logo.png'/>
which IMO is not very nice way of using images.
I would prefer to use resources= and prefix res set in <iu:with/> like in <g:Image field=.... resource=.../>
Is any way to use ui:images in more smartly way?

edit:
Added next day.
Is this question so hard or so stupid that nobody can answer - "Yes, this is the only way of using resources" or "No, you can use...."?
13 years ago
GWT
Writing numer of line in post, I mean line in this post. Now, after editing my first post this is line 43 which contains ctt.myMethod();
Apart from that, I added to MyClassTest in line 30 expect(Calendar.getInstance()).andReturn(now); but it nothing changes.
13 years ago
I don't have experience in testing that's why I'm asking for a help.

This is my example class which I have to test.


I tried to make test case but it doesn't work. I have "Unexpected method call clone()" in line 39. and others when I do some changes.
But I think that my thinking is not correct at all....

Could you correct mistakes?
Thank you in advance.
13 years ago
I have to test method which reads data from XML file (using DOM). I wonder if I should (and how to) mock xml file.
When I'm testing method which uses data from database, I have to mock database connection and data from base. What when I use XML?
14 years ago
applicationContext.xml

In OrderDetails is a reference @ManyToOne to OrderGeneral.
The problem is that I can not save OrderGeneral and referenced on it OrderDetails in one method/transaction. This is my method:


Exception:


OrderDetailsDAO is


Unfortunatly the problem is not in mapping, I checked it several times, and what is more saving another two connected object (ex Person and City which doesn't exist in base) ends with the same exception (of course another parent key is not found).
I faced up this problem 2 months ago and I'm still fighting with it.
Please for help.
I have problem with @ManyToOne which generate that exception:

In Person is references to City and Street. When I remove these references it works.
I put in a lot of time reading many threads and finding solution but the most similar case is here:
http://forum.springsource.org/showthread.php?t=86745
But there the problem was in the lack of some setters.





Help appreciated!
Unfortunatly, there is no null...
If I get already existing city object, it works fine:


but when the city object is going to be created w person in the same session it doesn't work




I don't know why, Hibernate can not find the primary key of the City which was inserted in the same session with Person. I'm using Oracle 10g.

Hibernate: select diagno.hibernate_sequence.nextval from dual
Hibernate: select diagno.hibernate_sequence.nextval from dual
Hibernate: insert into diagno.City (name, id) values (?, ?)
Hibernate: insert into diagno.Person (name, surname, city_id, id) values (?, ?, ?, ?)

Exception in thread "main" org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
.
.
Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (DIAGNO.PERSON_CITY_FK) violated - parent key not found

I want to use JavaMail which is a part of Java EE. I know that I can use standalone JavaMail librabry but it is not my purpose. I want to start using Java EE, and first use JavaMail classes.
I download and installed Java EE 6 SDK from
http://java.sun.com/javaee/downloads/index.jsp
Is it enough?

My question is, how can I use Java EE (for example use JavaMail classes) in Eclipse Classic WTP?
import.javax.mail.*; doesn't work. What should I do to import JavaMail from JEE platform?
I'm looking for video tutorials about Java EE 5. Something like tutorials from lynda.com but there is no tutorial about Java.
Of course, I know that some video tutorials suffer from a lack of quality... but in spite of this I want to try.
14 years ago
It turns out that I already had a getter getDwarfs() which returns a length of collection. When I changed bean name from dwarfs to dwarfsMap (and setter name setDwarfsMap) it started work. I think that that getter was a reason of my problems
14 years ago
How to inject TreeMap?
This map is fulfill in the application.
My beans

And setter in class House

Exception
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'house' defined in file [snowWhiteBeans.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'dwarfs' of bean class [pl.edu.agh.snowwhite.logic.House]: Bean property 'dwarfs' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

And what with generic data information Map<String, Dwarf>? Should bean contain this generic information?
14 years ago