Win a copy of Rust Web Development this week in the Other Languages forum!

Muztaba Hasanat

Ranch Hand
+ Follow
since Aug 30, 2013
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
3
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Muztaba Hasanat

Bear Bibeault wrote:JSPs get translated into servlets. You have an unconditional return in your JSP that is followed by something -- in this case HTML markup.

The servlet code that is generated to emit the HTML markup is after the return, and therefore is unreachable. This is not legal in Java.


Thanks a lot mate. You also suggested look into the generated java code that made me understand. Thanks again.
4 years ago
JSP
I am trying to bind checkbox value to spring bean as boolean. when use check the checkbox then it will take as true value otherwise false.

This is what I have done so far. I am using `Kotlin` as programming language and `Thymeleaf` with the html page.

html page


this is the bean,

this is the rest controller


the request is hit the controller successfully but how can I bind the value true when the checkbox is check and false otherwise.

Thanks in advance.
5 years ago
You have encounter with PECS(Producer Extend Consumer Super) rule. Since you are trying to add to the list that has extends Number, in that case you are not allow to add anything to the list.

this  SO thread may be helpful
You have encounter with PECS(Producer Extend Consumer Super) rule. Since you are trying to add to the list that has extends Number, in that case you are not allow to add anything to the list.

this SO thread may be helpful (link)[http://stackoverflow.com/questions/2723397/what-is-pecs-producer-extends-consumer-super?lq=1]
I have three entity. those are -




In these three entity I would like to perform following sql-

In this case `Account` entity has no relation with the `Organization` entity directly. `Account` entity has the relation via `Book`. How can I achieve this using hibernate criteria dynamic query ?  
I am very new to hibernate and jpa world. With hibernate `sessionFactory` I have write a criteria dynamic query like -


But some reading I have found that using EntityManager over SessionFactory make the code loosely couple with the hibernate implementation. So I have changed my code like this. -

Using EntityManager the code looks like much more verbose. On the other hand the first one using SessionFactory the code is much more cleaner. My question is, Using EntityManager is the only way to deal with criteria dynamic query or there are some cleaner way to do ?

Thank you.
I am trying to get some configuration from properties file using getResourceAsStream. But it is returning null. Here is my code -



this code is not working. the inputStream is null.

and the project structure is like -



but if I change the code like



then it is working.

if I am not wrong, class and the properties file should be placed in a same package. But I have seen many other code that they only mentioned application.properties in getResourceAsStream.

Now the question is, if it is obvious to mention the package name also if the class and file in not the same package or is there any other way to read file properties file to read with getResourceAsStream method.

Thank you.
5 years ago

Jesper de Jong wrote:Note that there is no keyword "extend". It should be "extends".


ohh sorry .. my mistake
5 years ago

Dave Tolls wrote:Let's add a method to B:


With extends you can now go:

Because you know that T will always be some form of a B.


So if I use extend keyword then I can ensure that the generic class or method can accept multiple subtype. Like :



5 years ago
Suppose I have a generic class and this class has a method :



Now I have a class hierarchy like :



Now if I instantiated generic class , then method also takes the subtype of class B.

So what is the reason of extend keyword in generic. That is if I define the generic class A in this way - .

explanation would very helpful.
Thank you.
5 years ago

Roel De Nijs wrote:

Muztaba Hasanat wrote:It works. I have posted in reddit. They said it is only IDE that gives this error.


Awesome! Have a cow for coming back and sharing the solution.


Thanks

Muztaba Hasanat wrote:

Roel De Nijs wrote:

Muztaba Hasanat wrote:could you give me your intellij forum post link ? Therefore I can also keep track the update.


I suggested you should submit a request, so I didn't submit one myself

ok


It works. I have posted in reddit. They said it is only IDE that gives this error.

Here is my reddit post link.
https://www.reddit.com/r/javahelp/comments/48lphm/how_to_write_a_hql_in_intellij_in_java_based/

Roel De Nijs wrote:

Muztaba Hasanat wrote:could you give me your intellij forum post link ? Therefore I can also keep track the update.


I suggested you should submit a request, so I didn't submit one myself

ok

Roel De Nijs wrote:You are correct! (I am a very recent IntelliJ user with only 2 months experience, so I didn't know that )

It seems you can use Annotation Config when you are using the Spring Facet, but this option is not available if you configure the Hibernate and JPA Facet. I have no idea how to solve it. Maybe contact IntelliJ IDEA support and submit a request?

PS. I have added this topic to the IDEs forum as well. Maybe someone knows how it can be solved.


thank you.

could you give me your intellij forum post link ? Therefore I can also keep track the update.

Roel De Nijs wrote:

Muztaba Hasanat wrote:In this name variable can not resolve.


I assume that's an error you get when trying to run your application, not when writing the code.

And what about using this query


Nope. I am getting this error when I am writing code. It is saying

Here is my screen shot :