Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!

Ankit Nagpal

Ranch Hand
+ Follow
since Sep 09, 2008
Ankit likes ...
Eclipse IDE Java
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
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ankit Nagpal

mallikarjun dontamsetti wrote:Thanks guys for reply. And i prefer DB Change. and thing i need some clarity. If one user has multiple skills i think it will be stored like this


when i get the data using joins then is it going to be a performance issue?



You are absolutely correct now, and as far as I know, joins are absolutely fine til the time you have the proper joining conditions on each and every joined table. It is a general practice to follow this approach during many-to-many associations.
Hi,

I am using java.util.List interface as a parameter in my web method (using JAX-WS) but when I use the wsgen utility, it gives me an error that interfaces cannot be used as a parameter as it cannot do a new List(). Also, I could also see an XML schema associated with WSDL in the <types> section. My questions:

1) When, in the request/response model, would it require a new List()?
2) I read that <types> section is always empty when we use RPC/literal style and use, why is it still there in the WSDL?

Ankit.
8 years ago

Tatiana Vorobeva wrote:As I understand, he want to use one column for all skills



Sounds trouble in the long run though.
If possible, try to correct the root problem in the db design.

Tatiana Vorobeva wrote:Hm.
I've found these docs: http://docs.jboss.org/hibernate/core/3.6/javadocs/org/hibernate/Criteria.html#createCriteria(java.lang.String)

According them:


So, try to use "com.test.Student.school" (where "com.test" = Student's class package) instead of "school"?

P.S.: maybe you know some good docs for learning how to use Criteria? I've started to learn Hibernate and want to read about Criteria.



There wasn't any execution errors in my code, just wanted to know the logic behind this dissimilarity. I found the answer to my original question. It (The Criteria API) returns only the main criteria class until we explicitly tell it to include all entities in the result (unlike HQL). The following line, if added to the criteria, would include other entities as well:



P.S.: You can start with the book "Java Persistence with Hibernate" by Cristian Bauer and Gavin King

mallikarjun dontamsetti wrote:if there are more than 10000 employee the data base table has 10000X10=100000 like it is going to be difficult. so please help me in this.



Well, that's what the DBMS is for. It's not going to be difficult for
a) the application i.e. maintainability
b) the developer i.e. ease of development and
c) the DBMS i.e. isn't it designed to effectively store this much?

it's still better as a single query can fetch you the desired result rather than selecting the whole data and applying the logic for search. Remember to use appropriate joins in the query.

E.g. if you want to search all employees with java skill-set, you would use the following sql query:



No business logic required at all.

Tatiana Vorobeva wrote:I'm not a specialist on this theme, just one question (sorry, if it's stupid):
Why do you use "Student.class" for the first criteria and simple String "school" in the second?



No question is stupid.

It is because we are creating a main criteria on Student class and the sub criteria (note that it is not session.createCriteria()) is on a property of that class. Hibernate internally creates a join as it knows that it is associated to the School class. The mapping is:

naveen yadav wrote:
after reading online about the working of Tomcat , i am developing a servlet container for servlet 2.3 specification.

i have created a Request class implementing the javax.servlet.ServletRequest interface. this interface has method public java.lang.String getRealPath(java.lang.String path) which is Deprecated.
when i implements getRealPath(String ) i get warning that : java uses or overrides Deprecated api

what should i do to remove that warning ?



use application.getRealPath(String) where application is a reference to Servlet Context and the parameter is the relative path of the file.
8 years ago
Hi,

I am using inner joins via HQL as well as Criteria API to understand the difference in execution between the two and found an interesting one:

I have two classes School and Student having a one-to-many association. On executing the 2 different code snippets given below and calling the list() method, SQL queries generated by both are same but:

- in 1st case (HQL), it returns Object[2] ([0] for Student and [1] for School)
- in 2nd case (Criteria API), it returns Student object only

What could be the explanation to this?



and

mallikarjun dontamsetti wrote:
i don't get you ..



It means that your db tables are not designed correctly. Implement many-to-many mapping for skills and your existing table. For e.g. (Assuming your existing table name is employee):

Employee: Employee ID (PK), Name, ....
Skils: Skill ID (PK), Skill Name, ...
Employee_Skills: Employee ID (FK to Employee), Skill ID (FK to Skills), and Employee ID + Skill ID would be the composite key for this table.

Map these tables in your hibernate based application and I am sure it would be a lot easier to search the skills now.

Anirban D Jumy wrote:
Suppose three columns are there id, fld1, fld2
Values are there 123, aaaa, ssss//123, wwww, ddddd// 123, zzzz, rrrrr

Now when runing the program I am getting aaaa, aaaa, aaaa instead of aaaa, wwww, zzzz



How can the identifier have same values for 3 different records? Did you check your DB if it has the correct data in the first place?

Ankit

Pawan Komaram wrote:Still my question is not answered. I am talking something like Man-in-the-Browser attack by just sending some spam or using some other technique. If the session Id is hijacked by any of the mechanism (by social engineering etc), is there a way to identify the attacker and ivalidate session.

Here the point is not how to prevent the session id hijacking but after hijack has happend, how can we identify that a request is not coming from the real user.



You could have a look at how to prevent your JSESSIONID cookie from being read/modified at the client side to stop the hacking. Making this cookie HttpOnly would prevent the read/modify operations and also follows a simple rule: Prevention is better than cure.

Ankit
8 years ago
Hi,

I am using the DOM API for a random XML operation and have a NodeList which contains the following 3 nodes (All element nodes):



In this list, I want to remove the duplicate node i.e. Node number 3. Does any one have any clues on how can I do the same?

Thanks in advance.

Ankit

amit punekar wrote:Hello,
Define the log category explicitly for your class or the package in which that class resides. Package will be a better approach so that you can turn debug on and off at package level.

Regards,
Amit



Hi,

Let's assume that I have various classes in the package a.b.c and a.b.c.d, would it be correct to do the following:



I tried this approach but still getting the same results.

Regards,
Ankit
Hi,

I am using log4j in my web application deployed on Tomcat server (Unix OS). As soon as I change the ROOT logger level to DEBUG (in log4j.xml), I am also able to see the Tomcat logs along with my web application logs in the same log file specified in the configuration file. Any ideas on this behavior?

My guess is that tomcat also uses log4j for logging and by changing the log level of the ROOT logger, it is inheriting the same.

Here's the log4j configuration file:



I am using the following code to get the particular logger:


Thanks in advance.
Ankit
Hi,

I have created my own custom task for Ant as follows:



I have placed the following ant build file in the same folder where this java class file is kept:



However, on executing it gives the error "taskdef class com.ant.AntTest cannot be found". I know it's a classpath issue but how do I fix it? Please note that this is my first ant hands-on.

Thanks in advance.

Ankit
8 years ago