Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Sanju Manc

+ Follow
since May 28, 2009
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 Sanju Manc

Thanks for the reply. I'm afraid I may not be able to implement this way.
Because our users have DB read-access, so they have an idea of the data . But they do not have update permissions, so I'm providing REST service to update the row as per the requirements.
They want to just send the primary column value and few other column values which require update, so based on that I need to update the DB.

1 year ago

I'm working with REST services. I need to publish a service for updating a record in DB. There are 14 columns and the user can send any number of parameters for updating.
That means he/she can update any number of columns for a particular row.
Can you please suggest what is the best way to go with this requirement?

I can use GET request to fetch the path parameters. But the doubt is that I'm using GET for updating something on the backend , is this the right way to do?
Is there any other way to implement this using POST request?

1 year ago
I'm using ibatis2.3 and spring2.0.8 with log4j framework.
The logs are showing the SQL executed, but without sql id.
Can you let me know how to print the sql id in the logs?

2 years ago

Is component-scan avilable in spring 2.0.8? I've read that @Component,@Resource annotations are avilable only from sping2.5.
When I uses Spring2.0.8 in class path , spring is allowing me to have context:component-scan in the application context file?
Is there any way to achieve component scanning using spring 2.0.8.

Due to the dependencies we have in the project, we need to use 2.0.8 spring version.

Thanks in advance.
2 years ago
Sorry for not formatting the code.
Thank you so much for replies Tim and Jesper. I've modified the code to use @Configuration and @Bean annotations and it works. As Tim mentioned, I could declare the bean(BeanD) with property values for constructor, so it can be used in TestSpringAutowire class which I've not tested though.
There are two ways to populate the bean instance variables:
1. create a bean using default constructor and populate the instance variables in calling class
2. use the overridden constructor with arguments to populate the instance variables, so the calling class can invoke the bean with the overridden constructor
The later can be achieved with Spring using either @component and @bean or with XML declaration, in this case how does spring initialize bean with dynamic constructor arguments?

2 years ago
In the spring application context , I've

<context:component-scan base-package="com.howtodoinjava" />

and a bean as below

In service class

Service implementation class has

And the test class is as follows

The output is "nullnull". Is it possible to reinitialize the bean with some properties in TEST class? Is there a way to instruct the spring not to use default contructor?
2 years ago
Thank for the explanation. I've changed the erroneous line as mentioned and autowiring works good.
I'm new to spring, appreciate if you could post the code sample and documentation urls.

Thanks in advance.
2 years ago
I've spring beans config with just

and TestSpringServiceImpl is as follows

and the test class with main as below:

In the above class if I've autowired annotation on the "filed" without SET method, the autowiring is not working.
But I've read the documentation, setting @Autowired on the filed shoudl work fine.
Can you please tell me if there is anything being done incorrectly?

2 years ago
Can mybatis mapper have array return type?
I've query like select dept_no from employee where emp_id in (1,2) which returns two rows.
mapper.xml has following
<select id="getDeptNo" resultType="int">
SELECT dept_no FROM employee
where ticker in
<foreach item="item" index="index" collection="array" open="("
separator="," close=")">

And in the mapper class , can I've
public int[] getDeptNo(String[] empId);

When I try this , it is throwing an exception java.lang.ClassCastException: [I incompatible with [Ljava.lang.Object;

I've to declare the returnType to "Integer" and have the mapper class declaration as public List<Integer> getDeptNo(String[] empId);

Why I can not get the array?
2 years ago
I'm using eclipse 3.4. I've imported web project into the eclipse. There are few custom tag libraries.

I could not get rid of the compilation errors in the eclipse
in tld files.
ERROR:The content of element type "tag" must match

I went thru previous topics and added jstl and standard jars in the build path of eclipse. I reopened eclipse IDE and restarted my machine, it did not help.

Can you pl. help in resolving this issue.