production vs development

is it necessary to change the structure of db while in production? as i was not getting a single exception and was working fine in development but when i deployed it, Db has started giving me errors
174 Replies
JavaBot
JavaBotβ€’7d ago
βŒ› This post has been reserved for your question.
Hey @Maxxx005! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1stβ€’7d ago
normally not if yu show us the what exactly you are doing as well as the errors, we might be able to help you If you change the DB structure for the application in development and you deploy that to production, you do have to perform equivalent changes there ofc
Maxxx005
Maxxx005OPβ€’7d ago
exception i am getting in my sts log when i run the project.
Maxxx005
Maxxx005OPβ€’7d ago
should i also send the log of production server?
dan1st
dan1stβ€’7d ago
that error measn you are missing that table your application references a table that isn't in the DB if you add an entity, you also need to add the table in the DB DB migrations can be useful for that purpose
Maxxx005
Maxxx005OPβ€’7d ago
i am using hibernate and hiibernate managees my db tables
dan1st
dan1stβ€’7d ago
Do you mean you configured automatic table updating?
Tomasm21
Tomasm21β€’7d ago
# JPA Configuration
spring.jpa.hibernate.ddl-auto=update
# JPA Configuration
spring.jpa.hibernate.ddl-auto=update
?
Maxxx005
Maxxx005OPβ€’7d ago
yes yes
dan1st
dan1stβ€’7d ago
Are you sure you don't have that overwritten anywhere? But in general, doing that is probably a bad idea
Maxxx005
Maxxx005OPβ€’7d ago
then what is the preffered way?
Tomasm21
Tomasm21β€’7d ago
Sometimes, ddl-auto=update only runs during application startup if there are changes detected in the entity mappings. If there is any issue with the entity itself (like missing annotations or improper configuration), Hibernate might not attempt to create the new table. Double-check your entity class to ensure the table and field mappings are correct. Enable detailed logging for Hibernate to see if it is trying to update the schema and to check for any errors related to schema validation or creation.
logging.level.org.hibernate.tool.hbm2ddl=DEBUG
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.tool.hbm2ddl=DEBUG
logging.level.org.hibernate.SQL=DEBUG
Does it create the table in development but not production?
dan1st
dan1stβ€’7d ago
using a migration tool like flyway
Maxxx005
Maxxx005OPβ€’7d ago
yes it is creating tables in development but giving exception in production. Also i have used both logging.level in my project.
Tomasm21
Tomasm21β€’7d ago
And yes I never used flyway, but I heard many recommendations of it for production. Either investigate deeply why currently the table is not created or go with flyway.
Maxxx005
Maxxx005OPβ€’7d ago
ok i am trying to find out solution with chatgpt, if i don't get one , i'll think of it. Thanks for replying sirπŸ™
JavaBot
JavaBotβ€’7d ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Maxxx005
Maxxx005OPβ€’7d ago
πŸ‘
Tomasm21
Tomasm21β€’7d ago
You're welcome.
JavaBot
JavaBotβ€’7d ago
πŸ’€ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Maxxx005
Maxxx005OPβ€’6d ago
one more question, i have deployed my backend on render, handled db on aiven. So whenever i am solving error, Which error should i solve, like error in render's log,aiven's log or in sts's log becuase all logs are giving different errors.
dan1st
dan1stβ€’6d ago
Well if you get an error in STS/locally, you shouldn't deploy it at all and if an error occurs in production, you should fix that as well
Maxxx005
Maxxx005OPβ€’6d ago
Before deployment I was not getting any error in devlopment and my project was running fine. Now both the places I am getting errors.
dan1st
dan1stβ€’6d ago
maybe both are actually the same problem but different errors but you should ensure both are fixed
FirasRG
FirasRGβ€’6d ago
Id simply use one reliable tool to follow the app lifecycle when in production
dan1st
dan1stβ€’6d ago
but to be honest, are you sure you need a complete built JAR? Do exploded files/the compiled class files not work?
Maxxx005
Maxxx005OPβ€’6d ago
you meant deployment?
Maxxx005
Maxxx005OPβ€’6d ago
i am getting this exception for all the tables.
dan1st
dan1stβ€’6d ago
forget these two messages - I thought this was another post
Maxxx005
Maxxx005OPβ€’6d ago
.?
dan1st
dan1stβ€’6d ago
Well your tables don't have primary keys
Maxxx005
Maxxx005OPβ€’6d ago
why is this happening? i mean i have added @Id annotation for the user,twit and like's IDs. other tables are made from mapping. Then Why is primary keys not being created?
dan1st
dan1stβ€’6d ago
Are you still using Hibernate DDL generation?
Maxxx005
Maxxx005OPβ€’6d ago
yes
dan1st
dan1stβ€’6d ago
Can you show the entities?
Maxxx005
Maxxx005OPβ€’6d ago
yes wait i am sending.
Maxxx005
Maxxx005OPβ€’6d ago
these are my 3 entities
dan1st
dan1stβ€’6d ago
Do you have a schema.sql?
Maxxx005
Maxxx005OPβ€’6d ago
what is that can you explain?
dan1st
dan1stβ€’6d ago
oh so itΓ„s a User <--> User relation?
Maxxx005
Maxxx005OPβ€’6d ago
you are talking about the tables? yes
dan1st
dan1stβ€’6d ago
Can you try using two 1:n relations with another entity
dan1st
dan1stβ€’6d ago
Stack Overflow
Is there a way to self-reference an entity using Spring JPA
I'm using Spring JPA and MySQL as the database. I have trouble with self-referencing its own entity. I know the code below would do self-referencing, but it actually creates a new table to do so. @...
dan1st
dan1stβ€’6d ago
or you could try mappedBy on both maybe: https://stackoverflow.com/a/13708470/10871900
Stack Overflow
Many to many with Hibernate and annotations for self referencing
My brain is starting to hurt thinking about this, is it as simple as: @ManyToMany(mappedBy = "following", cascade = CascadeType.ALL) private Set<User> followers = new HashSet<User>(); @
dan1st
dan1stβ€’6d ago
but before that, check whether you have a schema.sql file
Maxxx005
Maxxx005OPβ€’6d ago
No i don't have a schema.sql file.
Maxxx005
Maxxx005OPβ€’6d ago
then they are giving me this exception
Maxxx005
Maxxx005OPβ€’6d ago
after changes you told. 2025-01-17T23:07:12.091+05:30 DEBUG 95968 --- [Connect] [ restartedMain] org.hibernate.SQL  : alter table user_followers add constraint FK6rk047eulefv05mknxaea9qmb foreign key (followings_id) references user (id) Hibernate: alter table user_followers add constraint FK6rk047eulefv05mknxaea9qmb foreign key (followings_id) references user (id) 2025-01-17T23:07:12.162+05:30  WARN 95968 --- [Connect] [ restartedMain] o.h.t.s.i.ExceptionHandlerLoggedImpl  : GenerationTarget encountered exception accepting command : Error executing DDL " alter table user_followers add constraint FK6rk047eulefv05mknxaea9qmb foreign key (followings_id) references user (id)" via JDBC [Table 'defaultdb.user_followers' doesn't exist] in previous code. user_followers..etc is not gettiing created only.
dan1st
dan1stβ€’6d ago
Can you show the entities for that?
Maxxx005
Maxxx005OPβ€’6d ago
The entities I sent you are only giving this exception.
dan1st
dan1stβ€’6d ago
Didn't you do one of these tthings=
Maxxx005
Maxxx005OPβ€’6d ago
Yes I edited my code and did those things and got this exception.
dan1st
dan1stβ€’6d ago
Can you show the edited code?
JavaBot
JavaBotβ€’5d ago
πŸ’€ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Maxxx005
Maxxx005OPβ€’4d ago
Edited Entity And sts Exception
dan1st
dan1stβ€’4d ago
you could also try adding targetEntty=User.class to the ManyToMany but you probably need to do that
Maxxx005
Maxxx005OPβ€’4d ago
For that won't I need a particular follower and following class for writting vice versa onetomany and manytoone relation? That I don't have as I am making the table from user class itself.
dan1st
dan1stβ€’4d ago
you would need one additional class for the relation so
@Entity
public class User {
//...
@OneToMany(mappedBy="followedBy")
private List<Follow> follows;
@OneToMany(mappedBy="followed")
private List<Follow> followedBy;
//...
}
@Entity
public class Follow{
@Id
@ManyToOne
private User followedBy;
@Id
@ManyToOne
private User followed;
//...
}
@Entity
public class User {
//...
@OneToMany(mappedBy="followedBy")
private List<Follow> follows;
@OneToMany(mappedBy="followed")
private List<Follow> followedBy;
//...
}
@Entity
public class Follow{
@Id
@ManyToOne
private User followedBy;
@Id
@ManyToOne
private User followed;
//...
}
like that
Maxxx005
Maxxx005OPβ€’4d ago
yes letme try. @Id @ManyToOne private User followedBy; @Id @ManyToOne private User followed; should i give primary key to both variables?
dan1st
dan1stβ€’4d ago
In the Follow class, yes or alternatively you could also use a distinct id
Maxxx005
Maxxx005OPβ€’4d ago
@ManyToOne @JoinColumn(name = "follower_id") private Member follower; @ManyToOne @JoinColumn(name = "following_id") private Member following; in here in joincolum's name i have to give "user"?
dan1st
dan1stβ€’4d ago
? you just make two 1:n relations there
ayylmao123xdd
ayylmao123xddβ€’4d ago
in many to one you dont need to specify by what its mapped
Maxxx005
Maxxx005OPβ€’4d ago
Forget about everything, my code is running fine in these entity classes while development and not getting any errors but while in production i am getting this exception on render.com.
Maxxx005
Maxxx005OPβ€’4d ago
token is coming null and db exception
ayylmao123xdd
ayylmao123xddβ€’4d ago
probably because you dont use @generatedvalue annotation so id is null java.sql.SQLException: Field 'id' doesn't have a default value try something like this on the id field
@GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.IDENTITY)
oops yea try that
dan1st
dan1stβ€’4d ago
they already have that Can you show the DDL from the actual database?
ayylmao123xdd
ayylmao123xddβ€’4d ago
does it make a difference for id if its an object or a primitive value or no
dan1st
dan1stβ€’4d ago
normally it should be the wrapper if you are generating it
ayylmao123xdd
ayylmao123xddβ€’4d ago
maybe it throws that error cuz its an object value in the entity instead of primitive
dan1st
dan1stβ€’4d ago
?
ayylmao123xdd
ayylmao123xddβ€’4d ago
he has
private Long id;
private Long id;
dan1st
dan1stβ€’4d ago
that's exactly what I said is right Long --> wrapper for long
ayylmao123xdd
ayylmao123xddβ€’4d ago
yea interesting then wouldnt that solve the problem btw for the error at least id would get a default value
Maxxx005
Maxxx005OPβ€’4d ago
What do I do?
ayylmao123xdd
ayylmao123xddβ€’4d ago
try to set your id to long instead of Long and see if it helps it technically shouldnt help but worth to try ig
Maxxx005
Maxxx005OPβ€’4d ago
Ok let me try it is creating problem in other functions as i am unable to use the functions like equals etc. is there any alternate option? as i will have to change the whole structure.
ayylmao123xdd
ayylmao123xddβ€’4d ago
idk ask daniel
Maxxx005
Maxxx005β€’4d ago
Can you show the DDL from the actual database?
Maxxx005
Maxxx005OPβ€’4d ago
-----------------------------------------+ | user | CREATE TABLE user ( login_with_google bit(1) NOT NULL, req_user bit(1) NOT NULL, status bit(1) DEFAULT NULL, end_at datetime(6) DEFAULT NULL, id bigint NOT NULL, started_at datetime(6) DEFAULT NULL, background_image varchar(255) DEFAULT NULL, bio varchar(255) DEFAULT NULL, birth_date varchar(255) DEFAULT NULL, email varchar(255) DEFAULT NULL, full_name varchar(255) DEFAULT NULL, image varchar(255) DEFAULT NULL, location varchar(255) DEFAULT NULL, mobile varchar(255) DEFAULT NULL, password varchar(255) DEFAULT NULL, plan_type varchar(255) DEFAULT NULL, website varchar(255) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | +-------+--- Twit table: | twit | CREATE TABLE twit ( is_reply bit(1) NOT NULL, is_twit bit(1) NOT NULL, created_at datetime(6) DEFAULT NULL, id bigint NOT NULL, reply_for_id bigint DEFAULT NULL, user_id bigint DEFAULT NULL, content varchar(255) DEFAULT NULL, image varchar(255) DEFAULT NULL, video varchar(255) DEFAULT NULL, total_likes int NOT NULL, total_replies int NOT NULL, total_retweets int NOT NULL, PRIMARY KEY (id), KEY FKcuglcrx19c9w9fduo9b74d7sr (reply_for_id), KEY FKcupncc69r8ftdj6tpn96fcalc (user_id), CONSTRAINT FKcuglcrx19c9w9fduo9b74d7sr FOREIGN KEY (reply_for_id) REFERENCES twit (id), CONSTRAINT FKcupncc69r8ftdj6tpn96fcalc FOREIGN KEY (user_id) REFERENCES user (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | Likes table: ---------------+ | likes | CREATE TABLE likes ( id bigint NOT NULL, twit_id bigint DEFAULT NULL, user_id bigint DEFAULT NULL, PRIMARY KEY (id), KEY FKoyol2981ncfimsdv6r5xske5t (twit_id), KEY FKi2wo4dyk4rok7v4kak8sgkwx0 (user_id), CONSTRAINT FKi2wo4dyk4rok7v4kak8sgkwx0 FOREIGN KEY (user_id) REFERENCES user (id), CONSTRAINT FKoyol2981ncfimsdv6r5xske5t FOREIGN KEY (twit_id) REFERENCES twit (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
JavaBot
JavaBotβ€’4d ago
-----------------------------------------+
| user | CREATE TABLE user (
login_with_google bit(1) NOT NULL,
req_user bit(1) NOT NULL,
status bit(1) DEFAULT NULL,
end_at datetime(6) DEFAULT NULL,
id bigint NOT NULL,
started_at datetime(6) DEFAULT NULL,
background_image varchar(255) DEFAULT NULL,
bio varchar(255) DEFAULT NULL,
birth_date varchar(255) DEFAULT NULL,
email varchar(255) DEFAULT NULL,
full_name varchar(255) DEFAULT NULL,
image varchar(255) DEFAULT NULL,
location varchar(255) DEFAULT NULL,
mobile varchar(255) DEFAULT NULL,
password varchar(255) DEFAULT NULL,
plan_type varchar(255) DEFAULT NULL,
website varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+---
-----------------------------------------+
| user | CREATE TABLE user (
login_with_google bit(1) NOT NULL,
req_user bit(1) NOT NULL,
status bit(1) DEFAULT NULL,
end_at datetime(6) DEFAULT NULL,
id bigint NOT NULL,
started_at datetime(6) DEFAULT NULL,
background_image varchar(255) DEFAULT NULL,
bio varchar(255) DEFAULT NULL,
birth_date varchar(255) DEFAULT NULL,
email varchar(255) DEFAULT NULL,
full_name varchar(255) DEFAULT NULL,
image varchar(255) DEFAULT NULL,
location varchar(255) DEFAULT NULL,
mobile varchar(255) DEFAULT NULL,
password varchar(255) DEFAULT NULL,
plan_type varchar(255) DEFAULT NULL,
website varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+---
Twit table:
| twit | CREATE TABLE twit (
is_reply bit(1) NOT NULL,
is_twit bit(1) NOT NULL,
created_at datetime(6) DEFAULT NULL,
id bigint NOT NULL,
reply_for_id bigint DEFAULT NULL,
user_id bigint DEFAULT NULL,
content varchar(255) DEFAULT NULL,
image varchar(255) DEFAULT NULL,
video varchar(255) DEFAULT NULL,
total_likes int NOT NULL,
total_replies int NOT NULL,
total_retweets int NOT NULL,
PRIMARY KEY (id),
KEY FKcuglcrx19c9w9fduo9b74d7sr (reply_for_id),
KEY FKcupncc69r8ftdj6tpn96fcalc (user_id),
CONSTRAINT FKcuglcrx19c9w9fduo9b74d7sr FOREIGN KEY (reply_for_id) REFERENCES twit (id),
CONSTRAINT FKcupncc69r8ftdj6tpn96fcalc FOREIGN KEY (user_id) REFERENCES user (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
Twit table:
| twit | CREATE TABLE twit (
is_reply bit(1) NOT NULL,
is_twit bit(1) NOT NULL,
created_at datetime(6) DEFAULT NULL,
id bigint NOT NULL,
reply_for_id bigint DEFAULT NULL,
user_id bigint DEFAULT NULL,
content varchar(255) DEFAULT NULL,
image varchar(255) DEFAULT NULL,
video varchar(255) DEFAULT NULL,
total_likes int NOT NULL,
total_replies int NOT NULL,
total_retweets int NOT NULL,
PRIMARY KEY (id),
KEY FKcuglcrx19c9w9fduo9b74d7sr (reply_for_id),
KEY FKcupncc69r8ftdj6tpn96fcalc (user_id),
CONSTRAINT FKcuglcrx19c9w9fduo9b74d7sr FOREIGN KEY (reply_for_id) REFERENCES twit (id),
CONSTRAINT FKcupncc69r8ftdj6tpn96fcalc FOREIGN KEY (user_id) REFERENCES user (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
Likes table:
---------------+
| likes | CREATE TABLE likes (
id bigint NOT NULL,
twit_id bigint DEFAULT NULL,
user_id bigint DEFAULT NULL,
PRIMARY KEY (id),
KEY FKoyol2981ncfimsdv6r5xske5t (twit_id),
KEY FKi2wo4dyk4rok7v4kak8sgkwx0 (user_id),
CONSTRAINT FKi2wo4dyk4rok7v4kak8sgkwx0 FOREIGN KEY (user_id) REFERENCES user (id),
CONSTRAINT FKoyol2981ncfimsdv6r5xske5t FOREIGN KEY (twit_id) REFERENCES twit (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
Likes table:
---------------+
| likes | CREATE TABLE likes (
id bigint NOT NULL,
twit_id bigint DEFAULT NULL,
user_id bigint DEFAULT NULL,
PRIMARY KEY (id),
KEY FKoyol2981ncfimsdv6r5xske5t (twit_id),
KEY FKi2wo4dyk4rok7v4kak8sgkwx0 (user_id),
CONSTRAINT FKi2wo4dyk4rok7v4kak8sgkwx0 FOREIGN KEY (user_id) REFERENCES user (id),
CONSTRAINT FKoyol2981ncfimsdv6r5xske5t FOREIGN KEY (twit_id) REFERENCES twit (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
dan1st
dan1stβ€’4d ago
You are using GenerationType.IDENTITY so I think you should have AUTOINCREMENT configured for the table Do you have that locally?
Maxxx005
Maxxx005OPβ€’4d ago
Ya I had that locally, I even tried deploying with AUTO but I am facing same issue. also the ddl which I provided is of local db. Did you ask for the ddl of the db of production server?
dan1st
dan1stβ€’4d ago
yes, I meant the DDL of the production server you did say the error would only occur in production, right?
JavaBot
JavaBotβ€’3d ago
πŸ’€ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Maxxx005
Maxxx005OPβ€’3d ago
Apologies, I thought that you are asking of local server as you wrote actual db. Here i am sending ddl of production server db. Also in production server only 3 tables are being made, wherein local server total of 11 tables were made. User: CREATE TABLE "user" ( "id" bigint NOT NULL, "background_image" varchar(255) DEFAULT NULL, "bio" varchar(255) DEFAULT NULL, "birth_date" varchar(255) DEFAULT NULL, "email" varchar(255) DEFAULT NULL, "full_name" varchar(255) DEFAULT NULL, "image" varchar(255) DEFAULT NULL, "location" varchar(255) DEFAULT NULL, "login_with_google" bit(1) NOT NULL, "mobile" varchar(255) DEFAULT NULL, "password" varchar(255) DEFAULT NULL, "req_user" bit(1) NOT NULL, "end_at" datetime(6) DEFAULT NULL, "plan_type" varchar(255) DEFAULT NULL, "started_at" datetime(6) DEFAULT NULL, "status" bit(1) DEFAULT NULL, "website" varchar(255) DEFAULT NULL, PRIMARY KEY ("id") ) Twit: CREATE TABLE "twit" ( "id" bigint NOT NULL, "content" varchar(255) DEFAULT NULL, "created_at" datetime(6) DEFAULT NULL, "image" varchar(255) DEFAULT NULL, "is_reply" bit(1) NOT NULL, "is_twit" bit(1) NOT NULL, "total_likes" int NOT NULL, "total_replies" int NOT NULL, "total_retweets" int NOT NULL, "video" varchar(255) DEFAULT NULL, "reply_for_id" bigint DEFAULT NULL, "user_id" bigint DEFAULT NULL, PRIMARY KEY ("id"), KEY "FKcuglcrx19c9w9fduo9b74d7sr" ("reply_for_id"), KEY "FKcupncc69r8ftdj6tpn96fcalc" ("user_id"), CONSTRAINT "FKcuglcrx19c9w9fduo9b74d7sr" FOREIGN KEY ("reply_for_id") REFERENCES "twit" ("id"), CONSTRAINT "FKcupncc69r8ftdj6tpn96fcalc" FOREIGN KEY ("user_id") REFERENCES "user" ("id") ) likes: CREATE TABLE "likes" ( "id" bigint NOT NULL, "twit_id" bigint DEFAULT NULL, "user_id" bigint DEFAULT NULL, PRIMARY KEY ("id"), KEY "FKoyol2981ncfimsdv6r5xske5t" ("twit_id"), KEY "FKi2wo4dyk4rok7v4kak8sgkwx0" ("user_id"), CONSTRAINT "FKi2wo4dyk4rok7v4kak8sgkwx0" FOREIGN KEY ("user_id") REFERENCES "user" ("id"), CONSTRAINT "FKoyol2981ncfimsdv6r5xske5t" FOREIGN KEY ("twit_id") REFERENCES "twit" ("id") )
dan1st
dan1stβ€’3d ago
Maybe you can try to add AUT_INCREMENT to your id column And your existing code really works locally/in development?
Maxxx005
Maxxx005OPβ€’3d ago
Yes
dan1st
dan1stβ€’3d ago
Stack Overflow
Hibernate: "Field 'id' doesn't have a default value"
I'm facing what I think is a simple problem with Hibernate, but can't solve it (Hibernate forums being unreachable certainly doesn't help). I have a simple class I'd like to persist, but keep gett...
Maxxx005
Maxxx005OPβ€’3d ago
will i have to declare inheritance at class level?
dan1st
dan1stβ€’3d ago
Are you using inheritance in entities?
Maxxx005
Maxxx005OPβ€’3d ago
nope, I am talking about this article.
dan1st
dan1stβ€’3d ago
you don't need to declare inheritance if you don't use it but yes, if you make use of it, you need to declare it with the corresponding annotations
Maxxx005
Maxxx005OPβ€’3d ago
ok rn i am again trying out with AUTO then i willl go with inheritance
dan1st
dan1stβ€’3d ago
why inheritance?
Maxxx005
Maxxx005OPβ€’3d ago
As mentioned in the article.
Maxxx005
Maxxx005β€’3d ago
package hibtest.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; @Entity @Inheritance(strategy = InheritanceType.JOINED)
public class Mensagem {
protected Long id;

protected Mensagem() { }

@Id
@GeneratedValue
public Long getId() {
return id;
}

public Mensagem setId(Long id) {
this.id = id;
return this;
}
}
public class Mensagem {
protected Long id;

protected Mensagem() { }

@Id
@GeneratedValue
public Long getId() {
return id;
}

public Mensagem setId(Long id) {
this.id = id;
return this;
}
}
This message has been formatted automatically. You can disable this using /preferences.
dan1st
dan1stβ€’3d ago
the linked question is about the problem occuring with inheritance you should only use @Inheritance if you actually have entities extending each other which makes quite a bit of stuff more complicate and less likely to work
Maxxx005
Maxxx005OPβ€’3d ago
ohh understood! then what do i do If AUTO doesn't work out? By doing AUTO they are giving cors error:Access to XMLHttpRequest at 'https://connect-backend-umbj.onrender.com/auth/signup' from origin 'https://connect-2cgoq5uvw-harsh-vyas-projects-049c37b9.vercel.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
dan1st
dan1stβ€’3d ago
go back to IDENTITY and add AUTO_INCREMENT to the ID column in the DDL actually that looks like it worked Do you know what CORS is?
Maxxx005
Maxxx005OPβ€’3d ago
yes it is for connecting the backend and frontend. do you need to see the cors file?
dan1st
dan1stβ€’3d ago
check the CORS headers
Maxxx005
Maxxx005OPβ€’3d ago
Yeah
dan1st
dan1stβ€’3d ago
in the browser devtools
Maxxx005
Maxxx005OPβ€’3d ago
request: accept: application/json, text/plain, / content-type: application/json referer: https://connect-2cgoq5uvw-harsh-vyas-projects-049c37b9.vercel.app/ sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24" sec-ch-ua-mobile: ?1 sec-ch-ua-platform: "Android" user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36 Request URL: https://connect-backend-umbj.onrender.com/auth/signup Referrer Policy: strict-origin-when-cross-origin Request URL: https://connect-backend-umbj.onrender.com/auth/signup Request Method: OPTIONS Status Code: 403 Forbidden Remote Address: 216.24.57.252:443 Referrer Policy: strict-origin-when-cross-origin alt-svc: h3=":443"; ma=86400 cache-control: no-cache, no-store, max-age=0, must-revalidate cf-cache-status: DYNAMIC cf-ray: 904e4337fb650333-AMD date: Mon, 20 Jan 2025 10:08:19 GMT expires: 0 pragma: no-cache priority: u=1,i rndr-id: 4b37cd99-f872-4052 server: cloudflare server-timing: cfExtPri strict-transport-security: max-age=31536000 ; includeSubDomains vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Accept-Encoding x-content-type-options: nosniff x-frame-options: DENY x-render-origin-server: Render x-xss-protection: 0 :authority: connect-backend-umbj.onrender.com :method: OPTIONS :path: /auth/signup :scheme: https accept: / accept-encoding: gzip, deflate, br, zstd accept-language: en-US,en;q=0.9 access-control-request-headers: content-type access-control-request-method: POST origin: https://connect-2cgoq5uvw-harsh-vyas-projects-049c37b9.vercel.app priority: u=1, i referer: https://connect-2cgoq5uvw-harsh-vyas-projects-049c37b9.vercel.app/ sec-fetch-dest: empty sec-fetch-mode: cors sec-fetch-site: cross-site user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36 this is given in the header
dan1st
dan1stβ€’3d ago
What's the response that failed/caused the issue?
Maxxx005
Maxxx005OPβ€’3d ago
render log
dan1st
dan1stβ€’3d ago
I am asking for the response in the devtools oor is that the response yeah it seems like it
Maxxx005
Maxxx005OPβ€’3d ago
yes that is the response
dan1st
dan1stβ€’3d ago
the server is just not sending the CORS headers I think
Maxxx005
Maxxx005OPβ€’3d ago
ya maybe because i had given the wrong vercel domain. i have changed it lets see now. Not working out. Still having the same issue.
dan1st
dan1stβ€’3d ago
Can you show the CORS config?
Maxxx005
Maxxx005β€’3d ago
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();

// Allow requests from the React frontend
// configuration.setAllowedOrigins(Arrays.asList("http://localhost:3000"));
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
configuration.setAllowedOrigins(Arrays.asList("https://connect-2cgoq5uvw-harsh-vyas-projects-049c37b9.vercel.app", "http://localhost:3000"));
configuration.setAllowCredentials(true);

// Allow common headers including Authorization
configuration.setAllowedHeaders(Arrays.asList(
"Authorization",
"Content-Type",
"Accept",
"X-Requested-With",
"Origin",
"Access-Control-Request-Method",
"Access-Control-Request-Headers"
));
configuration.setExposedHeaders(Arrays.asList("Authorization"));
configuration.setMaxAge(3600L); // Cache preflight requests for 1 hour

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();

// Allow requests from the React frontend
// configuration.setAllowedOrigins(Arrays.asList("http://localhost:3000"));
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
configuration.setAllowedOrigins(Arrays.asList("https://connect-2cgoq5uvw-harsh-vyas-projects-049c37b9.vercel.app", "http://localhost:3000"));
configuration.setAllowCredentials(true);

// Allow common headers including Authorization
configuration.setAllowedHeaders(Arrays.asList(
"Authorization",
"Content-Type",
"Accept",
"X-Requested-With",
"Origin",
"Access-Control-Request-Method",
"Access-Control-Request-Headers"
));
configuration.setExposedHeaders(Arrays.asList("Authorization"));
configuration.setMaxAge(3600L); // Cache preflight requests for 1 hour

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
This message has been formatted automatically. You can disable this using /preferences.
dan1st
dan1stβ€’3d ago
and you are still getting the exact same CORS error with the exact same URL in the browser devtools? Can you access the site with curl -i?
Maxxx005
Maxxx005OPβ€’3d ago
ok so now i changed the domains to previous ones and cors error is removed and the same old error of id doesn't have default.. is coming. when i accessed the site with curl -i i got output: C:\Users\harsh>curl -i https://connect-chi-gules.vercel.app/ HTTP/1.1 200 OK Accept-Ranges: bytes Access-Control-Allow-Origin: * Age: 22955 Cache-Control: public, max-age=0, must-revalidate Content-Disposition: inline Content-Length: 644 Content-Type: text/html; charset=utf-8 Date: Mon, 20 Jan 2025 13:07:53 GMT Etag: "9c3b7f0a6cd316545fb1afbb895d844e" Last-Modified: Mon, 20 Jan 2025 06:45:18 GMT Server: Vercel Strict-Transport-Security: max-age=63072000; includeSubDomains; preload X-Vercel-Cache: HIT X-Vercel-Id: bom1::8pglv-1737378473717-261775c29117 <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.33661283.js"></script><link href="/static/css/main.0af02c3b.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
React App
Web site created using create-react-app
dan1st
dan1stβ€’3d ago
I meant accessing the backend with curl to get more information about the CORS error So you still get the SQL error in production but not in dev?
Maxxx005
Maxxx005OPβ€’3d ago
Yes Ok checking
dan1st
dan1stβ€’3d ago
if the CORS error no longer happens, it's fine For the SQL error, try adding AUTO_INCREMENT to the id column
Maxxx005
Maxxx005OPβ€’3d ago
ok State: 42S02 2025-01-20T13:54:20.838Z ERROR 1 --- [Connect] [nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : Table 'defaultdb.user_seq' doesn't exist 2025-01-20T13:54:21.740Z ERROR 1 --- [Connect] [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.dao.InvalidDataAccessResourceUsageException: error performing isolated work [Table 'defaultdb.user_seq' doesn't exist] [n/a]; SQL [n/a]] with root cause added auto inc in user table's id so getting this exception on render token:null 2025-01-20T13:54:16.343Z DEBUG 1 --- [Connect] [nio-8080-exec-3] org.hibernate.SQL : select u1_0.id, u1_0.background_image, u1_0.bio, u1_0.birth_date, u1_0.email, u1_0.full_name, u1_0.image, u1_0.location, u1_0.login_with_google, u1_0.mobile, u1_0.password, u1_0.req_user, u1_0.end_at, u1_0.plan_type, u1_0.started_at, u1_0.status, u1_0.website from user u1_0 where u1_0.email=? Hibernate: select u1_0.id, u1_0.background_image, u1_0.bio, u1_0.birth_date, u1_0.email, u1_0.full_name, u1_0.image, u1_0.location, u1_0.login_with_google, u1_0.mobile, u1_0.password, u1_0.req_user, u1_0.end_at, u1_0.plan_type, u1_0.started_at, u1_0.status, u1_0.website from user u1_0 where u1_0.email=? 2025-01-20T13:54:20.128Z DEBUG 1 --- [Connect] [nio-8080-exec-3] org.hibernate.SQL : select next_val as id_val from user_seq for update Hibernate: select next_val as id_val from user_seq for update 2025-01-20T13:54:20.445Z ERROR 1 --- [Connect] [nio-8080-exec-3] o.hibernate.id.enhanced.TableStructure : could not read a hi value also this
dan1st
dan1stβ€’3d ago
oh you still have GenerationType.AUTO You'd need GenerationType.IDENTITY if you want to use AUTO_INCREMENT
Maxxx005
Maxxx005OPβ€’3d ago
Ohh ok let me try. ok so some positive news!!!! that token is being generated and data is getting inserted in db but user_follower(the extra table which was created through mapping) is not getting created and likewise all the other extra tables will also throw the same errors ig. 2025-01-20T17:37:31.900Z ERROR 1 --- [Connect] [nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : Table 'defaultdb.user_followers' doesn't exist 2025-01-20T17:37:31.938Z ERROR 1 --- [Connect] [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.hibernate.exception.SQLGrammarException: JDBC exception executing SQL [select f1_0.user_id,f1_1.id,f1_1.background_image,f1_1.bio,f1_1.birth_date,f1_1.email,f1_1.full_name,f1_1.image,f1_1.location,f1_1.login_with_google,f1_1.mobile,f1_1.password,f1_1.req_user,f1_1.end_at,f1_1.plan_type,f1_1.started_at,f1_1.status,f1_1.website from user_followers f1_0 join user f1_1 on f1_1.id=f1_0.followers_id where f1_0.user_id=?] [Table 'defaultdb.user_followers' doesn't exist] [n/a]] with root cause java.sql.SQLSyntaxErrorException: Table 'defaultdb.user_followers' doesn't exist
dan1st
dan1stβ€’3d ago
well the table for the relation is missing
ayylmao123xdd
ayylmao123xddβ€’3d ago
show the user followers class
Maxxx005
Maxxx005OPβ€’3d ago
means? there is no such class, i am making that table from relations.
dan1st
dan1stβ€’3d ago
In your User entity, you have a user_followers relation and for that relation, you need a table
ayylmao123xdd
ayylmao123xddβ€’3d ago
show the user class then
Maxxx005
Maxxx005β€’3d ago
Forget about everything, my code is running fine in these entity classes while development and not getting any errors but while in production i am getting this exception on render.com.
dan1st
dan1stβ€’3d ago
see the followers field which references a user_followers table
Maxxx005
Maxxx005OPβ€’3d ago
yes understood but what change do i need to make?
ayylmao123xdd
ayylmao123xddβ€’3d ago
yea so why dont you use some other class to keep the followers
dan1st
dan1stβ€’3d ago
add the table to the DB
ayylmao123xdd
ayylmao123xddβ€’3d ago
tbh i would just make another class named UserFollows and keep the follows there way easier didnt u suggest that before terminator daniel
dan1st
dan1stβ€’3d ago
I suggested that already I think but they need a table in both cases
ayylmao123xdd
ayylmao123xddβ€’3d ago
yea but
dan1st
dan1stβ€’3d ago
like idk whether JPA supports self references
ayylmao123xdd
ayylmao123xddβ€’3d ago
in that case the relation will be different it will be one to many from user to the user follows class
dan1st
dan1stβ€’3d ago
CREATE TABLE `user_followers` (
`user_id` bigint NOT NULL REFERENCES `user` (`id`),
`follower_id` bigint NOT NULL REFERENCES `user` (`id`),
PRIMARY KEY (`user_id`, `follower_id`)
);
CREATE TABLE `user_followers` (
`user_id` bigint NOT NULL REFERENCES `user` (`id`),
`follower_id` bigint NOT NULL REFERENCES `user` (`id`),
PRIMARY KEY (`user_id`, `follower_id`)
);
something like that
ayylmao123xdd
ayylmao123xddβ€’3d ago
would that even work if jpa didnt support self referencing
Maxxx005
Maxxx005OPβ€’3d ago
yes sir creating new table. It is but then i will have to make lot of changes in many files. like change dtos,entity,service,util classes so that is why i didn't go that way.
ayylmao123xdd
ayylmao123xddβ€’3d ago
well up to you
Maxxx005
Maxxx005OPβ€’3d ago
i am trying this for now, if nothing happens that is the last option left for me or will switch to flyaway as suggested by daniel sir. Also @dan1st | Daniel sir do i also need to make twit's and like's id's column auto increment na?
dan1st
dan1stβ€’3d ago
Yes but in that case you'd need to add another entity As we said, I don't know whether it's possible to do it without a UserFollows (or similar) entity probably However, it should be possible to make that change without changing DTOs (at least if you aren't using stuff like mapstruct) - you would need to change the code mapping between DTOs and DAOs though it would in principle even be possible without changing any classes like
@OneToMany(mappedBy="follower")
private List<UserFollow> outgoingFollows = new ArrayList<>();
@OneToMany(mappedBy="followed")
private List<UserFollow> incomingFollows = new ArrayList<>();


@Transient
public List<User> getFollowers(){
return incomingFollows
.stream()
.map(UserFollow::getFollower)
.toList();
}
@Transient
public List<User> getFollowings(){
return outgoingFollows
.stream()
.map(UserFollow::getFollowing)
.toList();
}
@OneToMany(mappedBy="follower")
private List<UserFollow> outgoingFollows = new ArrayList<>();
@OneToMany(mappedBy="followed")
private List<UserFollow> incomingFollows = new ArrayList<>();


@Transient
public List<User> getFollowers(){
return incomingFollows
.stream()
.map(UserFollow::getFollower)
.toList();
}
@Transient
public List<User> getFollowings(){
return outgoingFollows
.stream()
.map(UserFollow::getFollowing)
.toList();
}
though you would still need to change your repositories (I am not saying it should be done that way, I'm saying it's possible)
Maxxx005
Maxxx005OPβ€’3d ago
Ohk applying the changes
dan1st
dan1stβ€’3d ago
These changes are (probably) necessary that one is just a possibility if you want a UserFollow class (to preserve compatibility)
ayylmao123xdd
ayylmao123xddβ€’3d ago
i would say just make the class code gonna look better
dan1st
dan1stβ€’3d ago
btw don't forget: If you didn't test it in development or it didn't work there, there's no point in deploying to production
ayylmao123xdd
ayylmao123xddβ€’3d ago
and loose coupling
dan1st
dan1stβ€’3d ago
I wouldn't consider that to be more loose coupling tbh it's just an additional indirection but it's still coupled in pretty much the same way (just using the additional indirection)
JavaBot
JavaBotβ€’2d ago
πŸ’€ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Maxxx005
Maxxx005OPβ€’2d ago
now i am facing another issue after adding auto increment,that when i open the domain it is directly requesting for profile and hitting the /home url which is supposed to hit after the login/signup. also token is which i said was generating is getting generated everytime when i open the domain with the same credentials i entered previously.
dan1st
dan1stβ€’2d ago
Can you show your security configuration? Did you configure any filters?
Maxxx005
Maxxx005OPβ€’2d ago
appconfig
dan1st
dan1stβ€’2d ago
Can you show your JwtTokenValidator?
Maxxx005
Maxxx005OPβ€’2d ago
yes
Maxxx005
Maxxx005OPβ€’2d ago
dan1st
dan1stβ€’2d ago
When generates the token and when exactly do you want it to be generated?
Maxxx005
Maxxx005OPβ€’2d ago
When I singup or signin
ayylmao123xdd
ayylmao123xddβ€’2d ago
question aside seems like its gonna be one of the longest threads 😱
Maxxx005
Maxxx005OPβ€’2d ago
Nope i don't think so, yesterday I Saw a thread with 312 messages
ayylmao123xdd
ayylmao123xddβ€’2d ago
oh yea true
dan1st
dan1stβ€’2d ago
and what actually generates the token in your code?
Maxxx005
Maxxx005β€’2d ago
JwtProvider: package com.Config; import java.util.Date; import static java.lang.System.currentTimeMillis; import java.util.stream.Collectors; import javax.crypto.SecretKey; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.stereotype.Service; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.security.Keys; @Service public class JwtProvider
{
SecretKey key=Keys.hmacShaKeyFor(jwtConstant.SECRET_KEY.getBytes());
public String generateToken(Authentication auth)
{
// String authorities = auth.getAuthorities().stream()
// .map(GrantedAuthority::getAuthority)
// .collect(Collectors.joining(","));

String authorities= auth.getAuthorities().toString();





return Jwts.builder()
.setIssuedAt(new Date())
.setExpiration(new Date(System.currentTimeMillis()+86400000))
.claim("email",auth.getName())
.claim("authorities", authorities)
.signWith(key)
.compact();
}
public String getEmailFromToken(String jwt)
{
jwt=jwt.substring(7);
Claims claims=Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(jwt).getBody();
String email=String.valueOf(claims.get("email"));
return email;
}


}
{
SecretKey key=Keys.hmacShaKeyFor(jwtConstant.SECRET_KEY.getBytes());
public String generateToken(Authentication auth)
{
// String authorities = auth.getAuthorities().stream()
// .map(GrantedAuthority::getAuthority)
// .collect(Collectors.joining(","));

String authorities= auth.getAuthorities().toString();





return Jwts.builder()
.setIssuedAt(new Date())
.setExpiration(new Date(System.currentTimeMillis()+86400000))
.claim("email",auth.getName())
.claim("authorities", authorities)
.signWith(key)
.compact();
}
public String getEmailFromToken(String jwt)
{
jwt=jwt.substring(7);
Claims claims=Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(jwt).getBody();
String email=String.valueOf(claims.get("email"));
return email;
}


}
This message has been formatted automatically. You can disable this using /preferences.
JavaBot
JavaBotβ€’2d ago
JwtProvider:
package com.Config;

import java.util.Date;
import static java.lang.System.currentTimeMillis;
import java.util.stream.Collectors;

import javax.crypto.SecretKey;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Service;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.security.Keys;

@Service
public class JwtProvider
{
SecretKey key=Keys.hmacShaKeyFor(jwtConstant.SECRET_KEY.getBytes());
public String generateToken(Authentication auth)
{
// String authorities = auth.getAuthorities().stream()
// .map(GrantedAuthority::getAuthority)
// .collect(Collectors.joining(","));

String authorities= auth.getAuthorities().toString();





return Jwts.builder()
.setIssuedAt(new Date())
.setExpiration(new Date(System.currentTimeMillis()+86400000))
.claim("email",auth.getName())
.claim("authorities", authorities)
.signWith(key)
.compact();
}
public String getEmailFromToken(String jwt)
{
jwt=jwt.substring(7);
Claims claims=Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(jwt).getBody();
String email=String.valueOf(claims.get("email"));
return email;
}


}
JwtProvider:
package com.Config;

import java.util.Date;
import static java.lang.System.currentTimeMillis;
import java.util.stream.Collectors;

import javax.crypto.SecretKey;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Service;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.security.Keys;

@Service
public class JwtProvider
{
SecretKey key=Keys.hmacShaKeyFor(jwtConstant.SECRET_KEY.getBytes());
public String generateToken(Authentication auth)
{
// String authorities = auth.getAuthorities().stream()
// .map(GrantedAuthority::getAuthority)
// .collect(Collectors.joining(","));

String authorities= auth.getAuthorities().toString();





return Jwts.builder()
.setIssuedAt(new Date())
.setExpiration(new Date(System.currentTimeMillis()+86400000))
.claim("email",auth.getName())
.claim("authorities", authorities)
.signWith(key)
.compact();
}
public String getEmailFromToken(String jwt)
{
jwt=jwt.substring(7);
Claims claims=Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(jwt).getBody();
String email=String.valueOf(claims.get("email"));
return email;
}


}
dan1st
dan1stβ€’2d ago
what calls that?
Maxxx005
Maxxx005OPβ€’2d ago
authcontroller
dan1st
dan1stβ€’2d ago
So what exact request are you making and how are you authenticating that request such that it generates a token that you don't want?
Maxxx005
Maxxx005OPβ€’2d ago
ok so done and dusted!!!! the problem was the jwt was not getting removed from local storage. so i removed it and the problem with the db was "sql_require_primary_key" this term in aiven doesn't allow a table without a primary key to be made.so that is why it was giving me such errors i disabled that button and deleted the jwt from local storage and my problem got solved.
JavaBot
JavaBotβ€’2d ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Maxxx005
Maxxx005OPβ€’2d ago
Also big thank you to @dan1st | Daniel , @ayylmao123xdd , @Tomasm21 and @FirasRG for replying and helping my problem get solved. Really means a lot. A big Thank you!!!
ayylmao123xdd
ayylmao123xddβ€’2d ago
woooohooooooooooo
JavaBot
JavaBotβ€’21h ago
πŸ’€ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?