Puspender Tanwar

Ranch Hand
+ Follow
since Apr 21, 2015
Puspender likes ...
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Puspender Tanwar

What would be the best choice for storing Ids in the persistence layer(JPA) if the database Id type is integer?

I prefer int over Integer :
1. int has some performance and memory benefits over Integer
2. since Ids are always non-nullable, there is no other reason to use Integer over int.

Please correct me if I missed something.
I have a executable application(jar) which pick credentials of the target application(cloud) from a YAML(cofiguration) file. User enters those credentials manually. The YAML file is loaded once in the single lifecycle of application/jar.
Until now, application was designed to pick the text password from file, but now came a requirement where the text format is not allowed to store in the YAML file. Because client doesn't want to let everybody know the password.
Is there any way I can store the encrypted password in the YAML file and then the application pick that encrypted password and then decrypt it and pass it to the target application(cloud)?
2 days ago
What would be the best choice among DATETIME and TIMESTAMP  for storing the below data(to the right side, i have written as per my understanding):

Now I am confuse between Datetime / Timestamp.
1. Since Datetime doesn't' store the timezone, how to store the activities time in DB?
my assumption : store the date time in any specific format in DB(suppose i convert the date time in IST and stored that converted time in DB) and during the time of retrieval it will be the responsibility of front end application to convert that IST to user specific timezone.

2. Using Timestamp instead of Datetime
Yes there will be benefit in terms of space as Timestamp require 4bytes whereas Datetime require 8bytes. Drawback is that it has year limitation - 1970 - 2038.

Please suggest me the best I should choose.
I am in need to use the logging file rolling on daily basis. So to check the behaviour I wrote the log4j.properties on Minute basis, but instead of creating a new file every minute, it is appending logs to the same file. Below is the properties file.

Logs are getting generating into output.log file.
Am I doing something wrong here?

2 weeks ago
ZonedDateTime is a part of Java 1.8, but I am in need to use 1.7 version. Do we have any class in 1.7 version?
2 weeks ago
This worked. Thanks

2 weeks ago
I am in need of converting the current time as this format :
But I don't know how to get this 'T' and '+' part. Please help.
2 weeks ago

I am from Java background, so can't understand how outside(5)(3) is working here.
By default, Tests are set to Rollback at the end. So I need to annotate my transactional method with @Rollback(false)
1 month ago
Forgot to paste the Test case. Here it is:
[code=java][@ContextConfiguration(classes = {PersistenceJpaConfig.class, ContextConfig.class})
public class TestJPA {

private UserJpaRepository userJpaRepository;

public void insertUser() {
User user1 = new User("puspender@fake.com","puspender", false, "12345");
System.out.println("saving user");

public void findAllUsers() {
Iterable<User> users = userJpaRepository.findAll();
for(User user : users) {
System.out.println(user.getName()+"\t"+ user.isLocked());

}/code] findAllUsers() test is working but insertUser() not working.
1 month ago
I am using Spring Data Jpa for my persistence layer and facing an issue where the code is able to fetch(read) the records but not inserting the entities to DB. Below is my code.
I don't know what wrong I am doing, please help.

1 month ago
Question: Query the list of STUDENT NAMES starting with vowels (i.e., a, e, i, o, or u) from STUDENT. Your result cannot contain duplicates.

Sample input(students name):


My doubt here is: why the OMPAL is matched, even the first character is 'O'(uppercase) and the value in IN clause is 'o'(lowercase).
Shouldn't the query be:
After reading some articles and questions, I decided to use ENUM('UNKNOWN', 'FRIENDS', 'PENDING_FIRST_SECOND', 'PENDING_SECOND_FIRST', 'BLOCK_FIRST_SECOND', 'BLOCK_SECOND_FIRST', 'BLOCK_BOTH') as the datatype for status