₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,994 members, 8,448,140 topics. Date: Sunday, 19 July 2026 at 08:03 PM

Toggle theme

Sweetguy10's Posts

Nairaland ForumSweetguy10's ProfileSweetguy10's Posts

1 2 3 4 5 6 7 8 9 10 (of 58 pages)

ProgrammingRe: SQL Query That Displays A List Assigned Only To Only The Logged In User Java by sweetguy10(op): 12:18pm On Nov 15, 2021
Singlecliq:
I can’t provide a Java implementation because I don’t develop on Java, but I believe algorithm should suffice.

1. There should be a middleware than only accepts authenticated request.
2. Save authenticated response of the user to the state.
2. Get the name of the authenticated user.
4. Fetch the customer table with the name, which is the marketer name in this case.
Thanks duly appreciated
ProgrammingRe: SQL Query That Displays A List Assigned Only To Only The Logged In User Java by sweetguy10(op): 5:28pm On Nov 12, 2021
richebony:
Ok
Maybe you can try the attached code
I tried running the code but it came back with an empty array response after inspecting the console. I made sure that I logged in with a Marketer type role and spring security detected Authorities type Marketer. Could it be from the authentication.getName parameter of the security context because in my user class what I have is firstName and lastName variables not Name variable ? I plan to refactor and change the first and last name variables to just Name . Do you think that should fix it ?

Thanks for your support Jah bless

ProgrammingRe: SQL Query That Displays A List Assigned Only To Only The Logged In User Java by sweetguy10(op): 7:40pm On Nov 10, 2021
Thanks much , I'll implement and get back to you with response
ProgrammingRe: SQL Query That Displays A List Assigned Only To Only The Logged In User Java by sweetguy10(op): 9:50pm On Nov 09, 2021
richebony:
I think you should paste the rest endpoint where you make the API call ..

To get the current user you can leverage on the Authentication object passed as a paramter on the handler and invoke the getPrincipal () method ...When you get the currently logged in user ,create a custom implementation on the repo .or better still you can use @Prefilter and filter based on the currently logged in user on the handler
Thanks very much for the response . I already have a custom implementation on the customer repo here it is .

@Query("select customer from Customer customer join customer.marketer marketer where marketer = :marketer"wink
List<Customer> findByMarketer(User marketer);

Now what I am thinking is how the passed :marketer parameter in the query get the logged in marketer name and display the Customers registered with the marketer's name. Thanks much I really appreciate your reply. I'll as well look into the getPrincipal method from spring security. Here is the controller where other endpoints are implemented

@RestController
public class CustomerController {

@Autowired
CustomerAccountService customerRepo;


@GetMapping(value="list/Customers"wink
public List<Customer> getCustomers()
{
return customerRepo.getCustomers();
}

@GetMapping(value = "list/customer/{id}"wink
public Optional<Customer> getCustomer (@PathVariable Long id)
{
return customerRepo.getCustomer(id);
}

@DeleteMapping(value="/deleteCustomer/{id}"wink
public void deleteCustomer(@PathVariable Long id)
{
customerRepo.deleteCustomer(id);
}
............................................................................................................................................
ProgrammingSQL Query That Displays A List Assigned Only To Only The Logged In User Java by sweetguy10(op):
I have a set of Users with different role types Marketer , Admin, General Manager. When a customer account is registered , there is a column that gets the name of the Marketer assigned to the Customer . I have created a @ManyToOne and @OneToMany relationship between Users and Customers. When User type Marketer logs in to the software , I want the marketer to see only customers registered to the logged in Marketer name. It seems complicated because first I need to get the logged in Marketer details using the username then get the first and last name then display customer list assigned to the name. Please help i need to deliver the project soon.

This is the Customer entity

@Entity
@JsonIgnoreProperties({"hibernateLazyInitializer","handler"})
public class Customer implements Serializable {

/**
*
*/
private static final long serialVersionUID = 8348682056500740593L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String userName;
private String password;
private String firstName ;
private String lastName;

private String gender;
private String Address;
private String idNumber;
private String phoneNumber;
private String email;

@DateTimeFormat(pattern = "yyyy-MM-dd"wink
private Date dateOfBirth;

@DateTimeFormat(pattern = "yyyy-MM-dd"wink
private Date registrationDate;


@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@ManyToOne(targetEntity = User.class,
fetch = FetchType.LAZY )
@JoinColumn(name="marketer_id"wink
private User marketer ;

@JsonBackReference
@OneToMany(mappedBy="customer_id",cascade = CascadeType.ALL, targetEntity=Investment.class)
private List <Investment> investment;

This is the User Entity

@Entity
public class User {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;

private String firstName ;
private String lastName;
private String username;
private String password;

@DateTimeFormat(pattern = "yyyy-MM-dd"wink
private Date createdDate;

@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(
name = "users_roles",
joinColumns = @JoinColumn(name = "user_id"wink,
inverseJoinColumns = @JoinColumn(name = "role_id"wink
)
private Set<UserRole> userRole = new HashSet<>();

@Enumerated(EnumType.STRING)
private UserStatus status;

@JsonBackReference
@OneToMany(mappedBy="marketer",cascade = CascadeType.ALL, targetEntity=Customer.class)
private List <Customer> customer;

This is the User Repository that contains a FindByUsername method that's being used by JWT authentication manager


@Repository
public interface UserAccountRepository extends JpaRepository <User, Long> {

Optional<User> findById(Long id);

User findByUsername(String username);
}
European Football (EPL, UEFA, La Liga)Re: Fc Barcelona Fan Thread: "més Que Un Club" by sweetguy10(m): 8:56pm On Aug 05, 2021
I am heart broken , I hissed like 300 times in five minutes , my wife kept telling me to go get a drink. Early in my 30s and never thought I would shed a tear for football. Messi is really gone huh I am depressed . Ah .. I am appalled beyond words, maybe its still a power game by barca board to make LaLiga bend their rules Nd not lose their biggest ever revenue generator . This is beyond me
CrimeRe: Man Chops Off 3 Persons' Heads In Imo (Graphic Pictures) by sweetguy10(m): 5:10pm On Jul 24, 2021
Something is definitely wrong with Imo state.
SportsRe: Argentina Vs Brazil: Copa America Final (1 - 0) - Live by sweetguy10(m): 12:20am On Jul 11, 2021
Someone should please drop streaming link
European Football (EPL, UEFA, La Liga)Re: Fc Barcelona Fan Thread: "més Que Un Club" by sweetguy10(m): 11:17pm On Jul 10, 2021
Where can I live stream the copa final match please ?
European Football (EPL, UEFA, La Liga)Re: Fc Barcelona Fan Thread: "més Que Un Club" by sweetguy10(m): 11:16pm On Jul 10, 2021
Please where can I live stream the copa final match ?
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 9:14am On Jan 22, 2021
Keep deceiving yourself ...
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 7:47pm On Jan 10, 2021
Woah......spent the day reading about Ateke Tom , Tompolo, Asari Dokubo, Gbaramatou kingdom, Egbesu, John Togo , Boyloaf, Icelanders, Greenlanders, Ogoni, MEND , NDA etc thanks to these two guys. Una don try i hail .


#saynotocultism
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 12:23pm On Jan 05, 2021
The guy shouted HBK so they will not hurt him because him self na airlord but not with that particular rolling squad ....who knows he might be the one that did the snitching on the aye wey dem come fall self ....when they leave , the guy sef will evacuate the premises.........


Say no to cultism , chai ! it will take lots to tackle cultism especially in Edo state as a whole ...
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 3:27pm On Dec 18, 2020
BigBabyJesus:
Faction after faction

From pyrates to buccanerrs to Vikings and after exhausting all scandanavian larps they turn to Sicilian mafia .

Very soon we go get Ninjas, Shaolins and when they finish with Asia dem go turn to Wakanda and from there marvel comics .

One day we will wake up to hear Ninja Turtles and Teletubies dey fight for Ekosodi UNIBEN back gate.

Pathetic losers.
Lol this guy dey craze grin grin grin
PoliticsRe: "Treat All Persons As Boko Haram Suspects Unless..." - Buratai Directs Soldiers by sweetguy10(m): 11:21am On Nov 23, 2020
GOD please i beg you , help me leave this country with my family ASAP ...NIGERIA HAS NOSEDIVED .
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 8:57pm On Nov 22, 2020
Abi shey the same PC no be NAS ?
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 9:40am On Nov 19, 2020
Someone should post it on filehost too so it can get a broader reach .
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 11:14pm On Sep 13, 2020
Nocturnal beings, apache na only una my toto clappa for . Asides the juju reasons , moving around only late at night will turn you to something else ....

I've been there, mine wasn't for cultism or juju but official ...

Las las wetin be the gain ?

Vehemently say no to cultism , please say no to culsitm .

It's deeper than these write ups , please say no to cultism
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 8:50pm On Jul 26, 2020
......things get gory really after even the game . I’ve seen hardened cultists run mad suddenly after their sojourn n tapes ( for those that survive hits et al ) , indeeed spirituality tied to cultism is extremely stronger than thought ......

I remember the words of my guy 4.... he said and I quote “ E get some kind things wey after person do , he gats do some kind things to clear way for am , or else Na madness or eternal hard luck/ sorrow .... “ the spiritual path...
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 2:03pm On Jul 22, 2020
NewDelhi:
Yesterday vibing when e dey rap... guy said something like ... bird wey Dey help bird fly..


But we never can tell sha
He said ..." Bird wey dey help Men Fly " ...

He is a philosopher , don't be so sure with your assertions.
PoliticsRe: APC Dissolves NWC At The Instance Of President Buhari by sweetguy10(m): 1:17pm On Jun 25, 2020
Give it to the Northerners , they know how to occupy space and even collect the space from they that allotted it to them . Politically they’ve gijacked APC from Tinubu ...it’s evident everywhere , give an aboki small space and in few years you’ll see him encroach your space and even pursue you . They’ve taken over the okada parks in almost all of Lagos . Same thing that was done to Afonja - we will learn by force !
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 1:10pm On Jun 25, 2020
When I was in 100L I ignorantly dated a black bra girl until she opened her mouth and told me herself . Though I’ve always noticed she wears black pants and bra/undies most times , most of them are lesbos etc .....how we went our separate ways is a story for another day though i had to run away from school for close to a month as she was threatening me with fire and brimstones....


In 400L I dated an Aloress , their male counterpart number 3 girlfriend . Screwed her anyhow till the guy got to know and started looking for me and even placed a bounty on my head , stupid idiot .....

The downside is those female cultists are always possessed . InFact most of them are witches , Nymphomaniacs , petty thieves and THEY ARE ALL PROSTITUTES .
PoliticsRe: Buhari Arrives APC NEC Meeting Convened By Victor Giadom by sweetguy10(m): 12:53pm On Jun 25, 2020
Please can someone enlighten me , why is Fayemi of Ekiti among those opposing Tinubu ? I understand the grievances of Amosun , the northern Governors and Amechi but what’s Fayemi’s reasons ? Is it because of 2023 presidency bid ?
CelebritiesRe: Bobrisky Dressed As A Man To His Father's Birthday Party by sweetguy10(m): 1:39pm On Jun 16, 2020
IMASTEX:
grin grin grin With that face. He is obviously thinking, why didn't I use a condom that day. grin grin
I laughed sooooooooooo hard ! You are a looney
BusinessRe: If You Are Uber Partner In Lagos, Please Share Your Experience Here by sweetguy10(m): 4:14pm On May 26, 2020
My car audio system stopped working after an interior car wash . Please what could be wrong ?
IslamRe: Millions Of Kano Muslims Ignore Social Distancing At Friday Prayers by sweetguy10(m): 4:52pm On May 22, 2020
How do I remove this there is no God but allah ?? I didn’t even post just mistakenly pressed it . This is insane ! I’m not a Muslim please Seun get that declaration off my profile .
CrimeRe: My Story As A Cult Member........initiation Phase Included... by sweetguy10(m): 3:31pm On May 19, 2020
I’m sorry I want to revisit the Juju is real and is not real topic again , I’m not trying to derail ... just trying to bring credence to the topic . Kindly view this thread and see REAL LIFE EXPERIENCES shared by lawyers ... then you’ll know there is more to this life .



https://twitter.com/segunoladejo_/status/1261267306866491395


Shalom
PoliticsRe: Coronavirus: Buhari “Addresses” Nigerians On COVID-19 (Video) by sweetguy10(m): 7:53am On Mar 23, 2020
This man’s brain is completely dead . This is the greatest mistake Nigerians have ever made politically .
EducationRe: What Course Did You Study In The Tertiary Institution And What's your job now? by sweetguy10(m): 1:46pm On Mar 22, 2020
Samadhii:
Thanks for responding.
Which information tech training Institute can u recommend with minimal charges
I learnt software dev at NIIT, the full stack Java course cost about 300k . The package includes HTML , JavaScript , RDBMS (Database management ) , Hibernate for ORM , Core Java and all enterprise Java frameworks - JSP , JSF , Struts , Spring MVC with well detailed materials/books and class exercises . Lots of people will tell you that NIIT is not as it was anymore but during my time (2017) I was lucky to have a very interactive and supportive tutor . You can as well try Aptech among others. I learnt Angular , PHP (Laravel) , Spring boot on my own .
EducationRe: What Course Did You Study In The Tertiary Institution And What's your job now? by sweetguy10(m): 11:59am On Mar 22, 2020
Samadhii:
Hello Sir, I'm also a graduate of biochemistry and I also have knowledge of web design. I know HTML and CSS. I want to upgrade to web development and cyber security. Please can u give advice on which languages to learn and how I can go ahead and where I can learn them
You can self teach yourself or go to any of the information tech training institutes in the country(which is better as you will have a coding tutor to help put you through some loopholes -no pun intended ) . The language of choice depends on what aspect of IT you want to go into .. If you're interested in mobile dev , I'll advice you learn Kotlin or Java , Data analysis/science - Python , Web dev - Php, Visual basic, Software development - Java , game dev - C#/C ..... Java cuts across lots of platform though and it has lots of libraries . Lots of corporations use Java for their back-end functionality too so you'll be readily needed .
EducationRe: What Course Did You Study In The Tertiary Institution And What's your job now? by sweetguy10(m): 10:09pm On Mar 21, 2020
Studied Biochemistry

Presently working as a software engineer + web developer

1 2 3 4 5 6 7 8 9 10 (of 58 pages)