|
Majid Karimi wrote: Sorry if this question is asked in the wrong spot
Your question is really about how the jshell works and not really about java.
Majid Karimi wrote: JShell jsh=JShell.create();
Did you try creating a new shell in the eval. Pseudo code like the following
JShell jsh1=JShell.create();
jsh.eval("""
JShell jsh2=JShell.create();
jsh2.eval("int j=4;");
""");
Also note that presumably you are doing this to experiment. You would not want to create application code like this. That is due to complexity and maintenance costs.
|
|
|
|
|
I've been dealing with a problem in my application that has me forced to change the HibernateQuery in a way that casts the existing DateTime column I have within my database into a date for further processing.
I've looked around a little on here already and found a supposed solution using sqlGroupProjection which ended up looking like this for me.
Projection dp = Projections.sqlGroupProjection("CAST("+sp.getIname()+" AS DATE",
"CAST("+sp.getIname()+" AS DATE",
new String[] {sp.getIname()},
new Type[] {StandardBasicTypes.DATE});
This does work to some the extent that it now generates this in the SQL statement
CAST(ierstelltAm AS DATE)
Which would be correct if it wasn't for the fact that something is now missing. Usually when Hibernate generates these statements they're given unique identifiers, one of them being y[i]_ and the other somehow relating to the table/entity used in the syntax of entity[i]_.
Since these are all inbuilt hibernate functions I had expected the above method to generate something along these lines
CAST(auftrag8_.IErstelltAm AS DATE) as y1_
based on the fact that the code previously generated using the criteria system did look like this.
auftrag8_.IErstelltAm as y1_
The question is now how do I correctly cast something to another data type using hibernate criterie, if it's not the sqlGroupProjection method mentioned in other places -- or is this a syntactical/logical error on my part?
|
|
|
|
|
How to make a scrolling background for a JPanel in java? I tried searching google but couldn't find a helpful one.
|
|
|
|
|
Do you mean manual scrolling, or something that scrolls by itself? And how would that affect any other controls that are in the panel?
|
|
|
|
|
I have a jpanel with an image as a background . how can i make that scroll like in a game ?
|
|
|
|
|
|
sir i don't want scroll panes . i want my jpanel background image to scroll horizontaly automatticaly.i am making a game.
|
|
|
|
|
|
But I have seen many people making that using pure java. Sir please if it is not possiblie Please help me for this:-
I am using this code to make an image the background of a jpanel -
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(bgImage, 0, 0, null);
}
Sir how can make the background a gif using this code. Sir please help me. I beg.
|
|
|
|
|
|
Sir you are the only one who replied to my questions. I am very very thankfull for you.
|
|
|
|
|
Hi, I'm a student of Computer Science I have a little task which is I want to read the certificate from USB Token(Entersafe PKI Manager - Epass2003 Auto) and after that, I print it on the Eclipse Console using Java Can Anyone Help me please with this solution.
|
|
|
|
|
I am an absolute beginner in java and l want to practice java code in eclipse code editors. I want to know that do l have to set up the environmental variables first to run programs in eclipse? And also is there will be any harm or changes to my system after setting variables? Please help me..
|
|
|
|
|
|
Recently, l have downloaded jdk in my Windows 10. Now, l didn't rememberd which version of jdk l have installed in my system. I want to know that which version of jdk is installed in my Windows. Please help me.
|
|
|
|
|
java -version
Type that command at the console. And try making use of the documentation.
|
|
|
|
|
Thank you so much for helping me sir but l didn't got your point that what you're trying to say.
|
|
|
|
|
Open a cmd window and type "javac -version". The result will tell you which version of the JDK you have installed.
|
|
|
|
|
|
Might want to also use the following commands. Just as with the other in a command window.
javac -version
where java
where javac
First will show the compiler version. Which should be the same as the java version.
Other two will show you where it is finding those commands so you can verify that it is what you expected.
|
|
|
|
|
Good afternoon! I'm trying to create a custom generic Bean Validator for the email of an author and the name of a category to verify that they are unique and I wish I could use a custom JPQL, the name of the persistence unit in persistence.xml and other variables. However, I don't know how to pass variables inside isValid, I only know how to hardcode them.
public class UniqueFieldValidator<T> implements ConstraintValidator<UniqueField,T> {
@Override
public boolean isValid(T value, ConstraintValidatorContext context)
{
EntityManagerFactory emf = Persistence.createEntityManagerFactory("project");
EntityManager em = emf.createEntityManager();
String jpql = "select a from Author a where a.email = :pEmail";
TypedQuery<Author> query = em.createQuery(jpql, Author.class);
query.setParameter("pEmail", value);
Optional<Author> optAuthor = Optional.of(query.getSingleResult());
if(optAuthor.isPresent())
{
return false;
}
return true;
}
}
modified 3-Jul-21 13:26pm.
|
|
|
|
|
Default Is Valid Implementation As Below public boolean isValid(Object value, ConstraintValidatorContext ctx)
|
|
|
|
|
Hi I am developing a library management system in net-beans. When I run it on my system it works fine however, if try to run it on another system it gives me an error of javax.persistence.Persistence.createEntityManagerFactory("path_to_database_on_my_system"). But this path to database must be changed in this function. How would I do this? Need Help.
|
|
|
|
|
Been messing around for hours and eventually decided to seek the assistance of the internet.
I am trying to make a program where I/the user can add elements into an array (Name, age gender). Once elements have been added to the array, I want to then be able to search a String (name) to find the desired name I am after in the array. The context of the program is adding Climbers to a Climber Database (just an array) of who has climbed what mountain (haven't attempted adding the mountain stuff yet).
In what I've written so far, I keep getting the return null, saying that the searched String cannot be found. I have a feeling that I am failing to pass the parameters of the added element in the array.
For example, I add a 'climber' with the name John, 19, Male in the Climber Class. I then go to the ClubStats class to getClimber and search "John", the only one in the array and I receive a null..
FYI I am using BlueJ here so at a serious basic level.
public class Climber
{
private String name;
private int age;
private String gender;
public Climber(String newName, int newAge, String newGender)
{
name = newName;
age = newAge;
gender = newGender;
}
|
|
|
|
|
I understand that a NPE can come from a variable or method returning null. But what I'm trying to do is get a bank account balance. To do this I first have to correctly enter the account id and nip, which I can do without problems. Then I have 4 options to pick from (right now I only have one implemented properly) so I pick Consulta (consult) and what I should be getting is the account balance but I get a NPE error. Can someone help me figure this out? The classes involve during this process should be SolicitudSaldo (consult balance), ATM, Cuenta (Account), BaseDatosBanco (Bank data base) and Transaccion (Transaction). I think the problem might have to do with how I declare ATM in my Jframe INTERFAZ_TRANSACCIONES.
I'll paste a link to my code since It's quite a lot and I don't want to make this post any longer. My project is in the master branch.
Heres a link to my project in gitHub
GitHub - Emmanck613/ATM_02[^]
|
|
|
|