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
β
This post has been reserved for your question.
Hey @Maxxx005! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose 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.
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
exception i am getting in my sts log when i run the project.
should i also send the log of production server?
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
i am using hibernate and hiibernate managees my db tables
Do you mean you configured automatic table updating?
?
yes
yes
Are you sure you don't have that overwritten anywhere?
But in general, doing that is probably a bad idea
then what is the preffered way?
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.
Does it create the table in development but not production?using a migration tool like flyway
yes it is creating tables in development but giving exception in production. Also i have used both logging.level in my project.
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.
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π
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.
π
You're welcome.
π€
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.
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.
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
Before deployment I was not getting any error in devlopment and my project was running fine. Now both the places I am getting errors.
maybe both are actually the same problem but different errors
but you should ensure both are fixed
Id simply use one reliable tool to follow the app lifecycle when in production
but to be honest, are you sure you need a complete built JAR?
Do exploded files/the compiled class files not work?
you meant deployment?
i am getting this exception for all the tables.
forget these two messages - I thought this was another post
.?
Well your tables don't have primary keys
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?
Are you still using Hibernate DDL generation?
yes
Can you show the entities?
yes wait i am sending.
these are my 3 entities
Do you have a schema.sql?
what is that can you explain?
oh so itΓs a User <--> User relation?
you are talking about the tables?
yes
Can you try using two 1:n relations with another entity
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.
@...
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>();
@
but before that, check whether you have a schema.sql file
No i don't have a schema.sql file.
then they are giving me this exception
after changes you told.
[2m2025-01-17T23:07:12.091+05:30[0;39m [32mDEBUG[0;39m [35m95968[0;39m [2m---[0;39m [2m[Connect] [ restartedMain][0;39m [2m[0;39m[36morg.hibernate.SQL [0;39m [2m:[0;39m
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)
[2m2025-01-17T23:07:12.162+05:30[0;39m [33m WARN[0;39m [35m95968[0;39m [2m---[0;39m [2m[Connect] [ restartedMain][0;39m [2m[0;39m[36mo.h.t.s.i.ExceptionHandlerLoggedImpl [0;39m [2m:[0;39m 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.
Can you show the entities for that?
The entities I sent you are only giving this exception.
Didn't you do one of these tthings=
Yes I edited my code and did those things and got this exception.
Can you show the edited code?
π€
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.
Edited Entity And sts Exception
you could also try adding
targetEntty=User.class
to the ManyToMany
but you probably need to do thatFor 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.
you would need one additional class for the relation
so
like that
yes letme try.
@Id
@ManyToOne
private User followedBy;
@Id
@ManyToOne
private User followed; should i give primary key to both variables?
In the
Follow
class, yes
or alternatively you could also use a distinct id@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"?
?
you just make two 1:n relations there
in many to one you dont need to specify by what its mapped
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.
token is coming null and db exception
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
oops
yea try that
they already have that
Can you show the DDL from the actual database?
does it make a difference for id if its an object or a primitive value
or no
normally it should be the wrapper
if you are generating it
maybe it throws that error cuz its an object value
in the entity
instead of primitive
?
he has
that's exactly what I said is right
Long
--> wrapper for long
yea
interesting then
wouldnt that solve the problem btw
for the error at least
id would get a default value
What do I do?
try to set your id to long instead of Long and see if it helps
it technically shouldnt help but worth to try ig
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.
idk ask daniel
Can you show the DDL from the actual database?
-----------------------------------------+
| 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 |You are using
GenerationType.IDENTITY
so I think you should have AUTOINCREMENT
configured for the table
Do you have that locally?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?
yes, I meant the DDL of the production server
you did say the error would only occur in production, right?
π€
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.
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")
)
Maybe you can try to add
AUT_INCREMENT
to your id
column
And your existing code really works locally/in development?Yes
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...
will i have to declare inheritance at class level?
Are you using inheritance in entities?
nope, I am talking about this article.
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
ok rn i am again trying out with AUTO then i willl go with inheritance
why inheritance?
As mentioned in the article.
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)
This message has been formatted automatically. You can disable this using
/preferences
.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 workohh 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.
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?yes it is for connecting the backend and frontend. do you need to see the cors file?
check the CORS headers
Yeah
in the browser devtools
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
What's the response that failed/caused the issue?
render log
I am asking for the response in the devtools
oor is that the response
yeah it seems like it
yes that is the response
the server is just not sending the CORS headers
I think
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.
Can you show the CORS config?
@Bean
This message has been formatted automatically. You can disable this using
/preferences
.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
?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
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?
Yes
Ok checking
if the CORS error no longer happens, it's fine
For the SQL error, try adding AUTO_INCREMENT to the id column
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
oh you still have
GenerationType.AUTO
You'd need GenerationType.IDENTITY
if you want to use AUTO_INCREMENT
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
well the table for the relation is missing
show the user followers class
means?
there is no such class, i am making that table from relations.
In your
User
entity, you have a user_followers
relation
and for that relation, you need a tableshow the user class then
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.
see the
followers
field
which references a user_followers
tableyes understood but what change do i need to make?
yea
so
why dont you use some other class
to keep the followers
add the table to the DB
tbh i would just make another class named UserFollows
and keep the follows there
way easier
didnt u suggest that before terminator daniel
I suggested that already I think but they need a table in both cases
yea but
like idk whether JPA supports self references
in that case the relation will be different
it will be one to many
from user to the user follows
class
something like that
would that even work if jpa didnt support self referencing
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.
well
up to you
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?
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
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)
Ohk applying the changes
These changes are (probably) necessary
that one is just a possibility if you want a
UserFollow
class (to preserve compatibility)i would say just make the class
code gonna look better
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
and loose coupling
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)
π€
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.
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.
Can you show your security configuration?
Did you configure any filters?
appconfig
Can you show your
JwtTokenValidator
?yes
When generates the token and when exactly do you want it to be generated?
When I singup or signin
question aside
seems like its gonna be one of the longest threads
π±
Nope i don't think so, yesterday I Saw a thread with 312 messages
oh yea true
and what actually generates the token in your code?
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
This message has been formatted automatically. You can disable this using
/preferences
.what calls that?
authcontroller
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?
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.
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.
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!!!
woooohooooooooooo
π€
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.