Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!

Rahul Babbar

Ranch Hand
+ Follow
since Jun 28, 2008
Hyderabad, India
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Rahul Babbar

Its an old issue but thought someone might benefit.
Tomcat seems to create the session when a jsp page is hit.
I was getting the same problem but fixed it using
in the jsp.

The following link was useful. Link
7 years ago
Hello,

I had a column defined as Varchar2(4000) in Oracle database and defined as the following in the Value Object.


I needed to change the column to allow more than 4000 chars, and since the maximum limit of varchar is 4000, i needed to change it to CLOB.
So, i changed the data type of the VALUE column in the database as CLOB.

Surprisingly, although i did not make any changes in the value object(like defining the column as CLOB etc), it has started working.
I am not sure whether it is the expected behavior and everything's good or i am in for a surprise when suddenly it will fail.

Any comments are appreciated.

Regards
Infact, i am probably not sure about the concept of EntityManager.

Since Hibernate Template is provided by Spring, which uses session internally, probably Spring needs to provide a similar wrapper over Hibernate's EntityManager.

Thanks

Rahul
Hello Henrique,

I did not get the solution for it, and had to change my API to accomplish it..

Like in my BaseDAOs for saving the entities, i introduced the callbacks like beforeSave(), afterSave() will null implmentation, and overrode those methods in the DAO of whichever entity i needed to save.

I think there might be a more elegant solution for it, but it satisfied my requirement so, i went ahead with that.

Regards,

Rahul
Thank you Alan and Mohamed..
7 years ago
Hi,

I have the following requirement.

I have a String that could be of the following forms.
1) /foo/{Id} where {Id} is a number
2) /foo;{SomeString} where {SomeString} is some string.

I need to give an error if the String is not of this form, otherwise i need to get "foo" and "{Id}" or "{SomeString}"

I can try to parse the String but i think Regular expressions should be used for this.

Can anyone direct me as to how regular expressions need to be used in this case.

Regards,

Rahul
7 years ago
Thanks Paul,

I wrote it up and it works...
Hi,

I have an XML that could be nested, eg



i want to get the value of a particular element, eg the value of element B is


and the value of element C is "C1".
Also, i want to use SAX parser and not the DOM parser.

I was wondering if there is a library which uses SAX parser to accomplish this, instead of me writing a SAX parser.

Thank you

Rahul
Yes, i did and the strange part as i mentioned before is that the query seemed to take quite a long time to execute when Hibernate was doing it but the oracle client like TOAD gave instantaneous results.
Hi,

I am using Hibernate with Spring and have come across this strange problem.

There is a table A which was not partitioned before.

However to optimize certain queries, it was partitioned on one of the columns.

With this change, other queries which do not use the partitioning on the view over the table seem to become slow...

The strange part is that these queries which do not use the partitioning columns seem to be slow only when executed from Hibernate and seem to be very fast when executed from a SQL client like SQLPlus or TOAD.

Is it expected? What can be done to avoid it?

Rahul
Hi,

I have this scenario where i need to audit certain operations and insert rows in some audit table.
So i have taken this approach, whenever the method A in class A is called which does that operation, i call my auditService's method B to insert the record in the audit table. Now, i have marked the propagation on method B as REQUIRES_NEW so that always a new transaction is created whenever the audit record is created.

I am able to successfully make it work but i was thinking is it possible to start the second transaction in a second thread so that the initial thread is not delayed in any way.
I could use the java.util.Timer API for it, but somehow something doesn't look right.

Any thoughts/suggestions please.

Thank you

Rahul
7 years ago
i have a large no of methods written for returning the XML type data, and repeating the code for all the methods just because of a different type of data conversion doesn't look good to me.

Because after some other time, a different content type requirement might come, and i dont want to rewrite all the methods just because the content type is different(unless the business logic requires some different processing for different content type)

So, what i am having right now, is that i get my data object from the backend to the jersey servlet and then based on the request parameter convert it to either JSON or XML(and that code is common).

Also, it looks like with Jersey, we can specify 2 or more content types for the same method, and that seems to be ok for what i am trying to do.

Thank you
7 years ago
Hi David,

I am using Jersey framework for this and eventually i want the requests like foo.json or foo.xml to go to a single method in the Servlet, but i am not sure whether if my urls are different in these cases(foo.json or foo.xml), how will jersey handle the request and how will i read the ".json" part.

Also, i think Jersey provides an annotated way of handling both xml and json in the same method using jaxb but i am not using it because of some other related complexities. so i am using a custom way to convert object to xml or json

Thank you
7 years ago
Hi,

I am using Spring's Hibernate template to save the entities.

I tried to use entity callback methods like PostPersist, PreRemove but they are not invoked.

Also, i read somewhere that these methods will work only if we use JPATemplate instead of Hibernate template.

Are there any similar lifecycle methods that we can use while using HibernateTemplate.

Thank you

Rahul
Oh...you are right Bill,

i was confused between the two.

I think i will go ahead with the way suggested by Paul to pass the parameter in the request instead.

Thank you

Rahul
7 years ago