Matthew Vahedi

Greenhorn
+ Follow
since Jan 05, 2012
Merit badge: grant badges
For More
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
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Matthew Vahedi

Hi,

Which IDE or compiler are you using?
6 years ago

Stephan van Hulst wrote:No, libraries don't need a main method.

Can you show us your POM, the command you use to compile the project, and its output?



Hi,
Thanks for your guide. Unfortunately, it's a project belong to an organization and my team lead said I'm not allowed to post anything project-related to this forum Sorry about that! But thanks again pointing out the quick answer.

Cheers,
6 years ago
Hi,

I'm trying to build a spring boot application which consists of two modules ( Persistence, Web). The persistence module only supposed to do persistence job hence I thought no need for main method/class. The Web module is where I'm implementing my restful logic and hence I considered that's where I need main method. However, when I try to compile this project using Maven, there is an error saying "unable to find a suitable main class" for the Persistence module!
My questions is, Should all modules have a main class?! if yes, then how should I add a main class to a module that is a only for persistence purpose?

Thanks,
6 years ago
Hi,

I have the following Rest service in my Spring and am interested to log an exception when the url is called with an improper data type.
For example if users use a url that contains an "id" larger than what "int" can accept, this method won't accept it but I want to log that as an exception on the server-side. Any idea?





Cheers,
8 years ago
Hi all,

Can you please explain how it is possible to call getIntent() method without using class name? I don't see any Static import or static method declaration!



Thank you.
8 years ago
if I only select the "student_name" I will receive the following error message:

javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'student_name'.

And if I only select "student_id" which is also my primary key, it throws the following exception:

The class 'java.math.BigDecimal' does not have the property 'student_id'.


I think the definition of .createNativeQuery() method doesn't allow query without entity classes! it's weird. when I use a dummy entity class there is no problem.

Any idea?

Jaikiran Pai wrote:
So it really isn't a problem in JPA or Hibernate. Whatever value has been fetched is being displayed in that JSP and it appears that the JSP is written such that it is expecting the string literal "student_name" to be a number, which obviously is wrong. So the fix needs to be done in the JSP.



Hi,
Let me write down some of the codes, I couldn't find out what may be wrong in my JSP.
The data type of "student_id" in the table is NUMBER and I guess this is the source of problem, but then the question is how can I use it properly?

My Controller:



My DAO:


My JSP:

Jaikiran Pai wrote:Can you post the entire exception stacktrace? That exception is an indication that the query is working fine but somewhere something is incorrectly using student_name as a number.



Hi,

I receive this exception: NumberFormatException for input string "student_name".

Fields in my student table: student_id, student_name, student_age

My query statement: select student_id, student_name from student


Jaikiran Pai wrote:I don't think you need a dummy entity for any of this. What happened when you tried the code that I posted in my previous reply? I could have tried it myself but I don't have the necessary setup to quickly try this.



Well,

I just managed to solve the problem, so, I write down the solution here for those who may refer to this post in the future.

Problem:

I wanted to query a table using native sql language ( instead of JPQL ), the problem was that I wanted to query my table on selective columns not all columns.

solution:

You must create a custom Entity class that only contains your selective fields ( not all fields of your table because in that case you will receive "invalid column name" exception ). One important thing to remember is that you must include a primary key in your custom entity class (this is mandatory).

Cheers,
Hi,
This is a Select statement, hence I need to use a result mapping class in the createNativeQuery() method. what that mapping class should look like?


Have you tried:


Thanks Jaikiran. I will try it and will come back with the result.
Hi,

A "student" table with student_name, student_id, student_age columns.

I want to run a command in native SQL language ( JPQL not an option ).

Sql command: select student_name from student

The above command does not select all the columns hence I can't use Student entity object as my result Class.

Can you please tell me what is the solution to this problem? ( I tried the following code but I receive: org.hibernate.MappingException: Unknown entity

Hi everybody,

Thanks for answering my previous question, those are great answers and helped a lot.

Now..

I have got a View that fetches it's result from different tables. There is no primary key in this View. I'm using Hibernate JPA for the rest of my Oracle tables.

Questions:

1- Can I create an Entity class for this View? ( What should I do for the lack of primary key? )

2- Where can I place the SQL ( not JPQL ) command that creates this View? My guess is inside DAO class but not sure how and what API must be used?

Thanks in advance.

Cheers,
Hi,

I'm confused! somewhere I read that JPA is part of EJB 3.0 specification and Hibernate implements JPA, then in other places people talk about whether to choose JPA or Hibernate!
Can someone please shed light on these definitions?

Thanks in advance.

Cheers,