Dilshan De Silva

+ Follow
since Jan 19, 2014
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dilshan De Silva

I there way to write this cursor in java jpa criteria query...

In my Spring hibernate application, When I try to insert same data twice throws above error.
In here I have 2 Entity classes organisation and division, mapped with 1:M relationship.
To save Org and division I used 2 UI's,1st save the orgs and then those orgs are load into drop down in division insert ui. So in there when I save for 1st time its work fine.But the 2nd attempt with the same data gives above error.I used sequence properly.
Divition add method :

Organisation Entity :

Divition Entity :

My DAO save method Use saveorupdate.(I tried merge it didn't work either)
Anyone who knows what went wrong in code?
I want to add auto increment number as PK to intermediate table in M:M mapping. I used oracle db and problem is when I save object it only insert PK's of other 2 tables to intermediate table. Hibernate not calling the sequence and there for it gives the error that null value cant insert to intermediate table.
Is there way to call sequence in intermediate table?

Jayesh A Lalwani wrote:What's wrong with it?

this is my spring xml after make changes you have mentioned.

There is no session factory bean and I cant set session factory to DAO class as i done earlier.
soo how to change my DAO class and annotate with Transactional.
7 years ago

Jayesh A Lalwani wrote:For looking up your data source from JNDI, you have to do

Replace JNDI-name with the name of your JNDI data source.

For using the JBoss transaction manager, do

These setting are pretty much what you find all over the net. If you have tried them already, and they are not working, you will have to figure out what the problem is by looking at the error messages.

how do I change this code.
7 years ago

Jayesh A Lalwani wrote:You need to look up the data source from JNDI instead of DriverManagedDataSource. Also you should use the JTATransactionManager. JTA transaction Manager will use the transaction manager provided by JBoss

can you give me sample code or replace my code with changes...
I have tried several and non of them succeed..
7 years ago
My project initially develop using with out persistence unit and project is spring,Struts2 hibernate intergration one. Now I need to use jboss connection pool and persistence unit.I need to handle transaction by conatainer also not like in the code i posted(dao). Please change my code to meet that requirement.
current spring.xml

sample DAO class

7 years ago

Joe Ess wrote:The Struts jQuery plugin uses a different library which is well-integrated with Struts and has numerous examples: GridTag.
If you are committed to jqgrid, you have a challenge with both documentation and support. Here is one example, but I can't speak to it's correctness.

Thanks friend really appreciate your help...
i'll look into your example tomrw....
7 years ago
I need to try some crud application with jqgrid and struts2. But after google 2hrs I cant find clean example of those. But there are many examples of jqgrid with spring mvc step by step examples. I need that kind of step by step example to start. Please give ref links to jqgrid+struts 2. Thanks.
7 years ago

Winston Gutkowski wrote:
Sure. Separate your client logic from whatever else your app needs to do (db, state managaement, whatever). Changing jars all the time suggests that you have a 'desktop app', like Word, so it stands to reason that whenever you have a change, you'll have to change all the 'desktops'.


So if I separate logic from view where the logic will run,guess it would be app server?..If so how do I connect view with logic( Guess logic is still run in client pc).
I thought of a solution like same jar access by many user,but if I do that static variables will cause problems right?
7 years ago

Stephan van Hulst wrote:I would argue that it shows interest in the field you are in. I don't know how the culture is where you live, in that regard, but where I live I would ask the interviewer for their thoughts, if I didn't know the answer to one of their questions.

Remember that you are on equal footing with the interviewer. You are not only asking them if you can work there, they are also asking you to work for them. They aren't doing you a favor.

Got your point.
But is there no way doing that, I mean without web?
7 years ago

Stephan van Hulst wrote:Why didn't you ask the interviewer?

It isnt polite right?
7 years ago
I had a java based interview today.
in there I explain one of my project that is 2 tier j2se application(client pc for view and business logic and db server). So I also said main problem in here is if we want to update jar file we have to update in all the client pc's.I also said as a solution for this we can move on to web based application.
So then interviewer asked from me ....
Is there other way to my problem with out move to web solution. I dnt know the answer for this.
Soo can anyone explain solution for this problem without using web based app?
7 years ago

Jeanne Boyarsky wrote:We ask people to cite the sources of questions. This looks like it is from here.

1) I don't think that is correct. Think about which fields could be derived from other fields.

2) Yes

3) Yes

4) Yes. 'co' should probably be uppercase since state abbreviations are upper case

5) That works. Do you know how to write it with in an "in" clause?

6) Yes

7) You aren't using a union

8) Yes

9) Yes

11) Look at the fields you are returning vs the fields they asked for

Note: I didn't run them so "yes" means "it looks right"

Thanks. Any suggestions for 1 and 10th quetions?
I have done some online SQL test for practice... But i cant fine any correct answers for the test. Can any one mark my answers for correctness?

MH Software, Inc.
SQL Test

The purpose of this test is to assess your general knowledge of SQL and database concepts. Please don’t
worry about a particular kind of syntax for a particular SQL Engine. Focus on getting the data required.
The table shown below depicts a typical database with 4 tables in it. The questions on this test are based on
these database structures. As a warning, some of these questions are extremely hard. Please do the best you
can and answer as many questions as you can. The test is solely to give us an idea on your level of SQL

Good Luck!

Customer Invoice LineItem Product
Customer_ID (PK) Int
Invoice_No (PK) Int
Customer_ID (FK)

Part_No (FK)

Part_No (PK) Int

1) Strictly speaking, the Invoice table contains two fields it shouldn’t. Identify the unnecessary fields.



2) Write an SQL Statement to list all customers sorted by name.

select customerid from customer order by name

3) Marketing wants to target computer companies for a direct mailing. Write a query that lists all
companies with the words “Computer” or “Software” in their name. Assume the database is not
case-sensitive for string comparisons.

select c.name from customer c where c.name like '%Computer%' OR like '%Software%'

4) Write an SQL Statement to list all invoices for customers who are located in the state of Colorado
(CO). Required output fields are: Customer ID, Customer Name, Invoice No, Sub-Total, Total.
Sort the results by City and then Zip cod

select c.customerid,c.name,i.ino,istot,i.tot
from customer c join invoice i
on c.customerid=i.customerid
where c.state='co'
order by c.city,c.zip

5) Write an SQL statement that lists all invoices for customers located in CO,CA,AZ,MT,WY,
WA,OR,ID, NM or UT, and the invoice date is within a specified date range known as TStart to
TEnd. Required fields and sort criteria are the same as question 3.

select c.customerid,c.name,i.ino,istot,i.tot
from customer c join invoice i
on c.customerid=i.customerid
where c.state=('co' or 'ca' or 'az' or 'MT'or 'WY' or 'WA' or 'OR' or 'ID' or 'NM' or 'UT'
) AND i.invoicedate >=to_date('Tstart','dd/mm/yyyy') and i.invoicedate <=to_date('TEnd','dd/mm/yyyy')
order by c.city,c.zip

6) Write an SQL Statement to list the following items: Customer ID, Customer Name, number of
invoices, sum of total for invoices. Ensure that all customers are returned in the result set.

select c.customerid,c.name,count(i.ino),sum(i.tot)from customer c left join invoice ion c.customerid=i.customeridgroup by c.customerid

7) Re-write the statement from question 6 using a UNION.7) Re-write the statement from question 6 using a UNION.write the statement without using a UNION.
select c.customerid,c.name,count(i.ino),sum(i.tot)
from customer c, invoice i
where c.customerid=i.customerid
group by c.customerid

8) Write an SQL Statement to list the following items: Customer ID, Customer Name, Number of
invoices, sum of total for invoices for all customers with more than $50,000 in total sales.

select c.customerid,c.name,count(i.ino),sum(i.tot)
from customer c left join invoice i
on c.customerid=i.customerid
group by c.customerid
having (sum(i.tot)>50000)

9) Referential integrity constraints were accidentally destroyed for the relationship between the
LineItem table and the Product table; as a result, parts were deleted from the product table that
should not have been. Write a query that will list the distinct part numbers in the LineItem table
that have no corresponding entry in the Product table.

select *
from lineitems l
where l.part_no NOT IN (select p.part_no
from product p)

10) Research has determined that when product 1234 and 2345 are shipped together, product 2345
loses its potency. Write an SQL statement that lists all invoices that have both part numbers on the
same invoice.

no idea

11) Because of poor data entry policies there are a lot of duplicate customers in the database. Write a
query that will list all customers where there exists another customer with the same phone number.
Displayed fields should be: Customer Name, City, State, Phone, DupeCustomer Name,
DupeCustomer City, DupeCustomer State, DupeCustomer Phone.

select c.name,c.city,c.ctate
from customer c
group by (c.phone)
having (count(c.phone) > 1)