Size: a a a

Spring Framework and more

2020 February 05

РН

Роман Нагаев in Spring Framework and more
Ved Prakash
Hello there I am facing problem in spring boot with jpa data insertion iam try to do with spring 2.2.4 help me
what kind of problem?
источник

VP

Ved Prakash in Spring Framework and more
I am not able to insert
источник

VP

Ved Prakash in Spring Framework and more
Data
источник

РН

Роман Нагаев in Spring Framework and more
Ved Prakash
I am not able to insert
is there any errors?
источник

VS

Vitaly Sirotkin in Spring Framework and more
Ved Prakash
I am not able to insert
Why?
источник

◉ⓁⓊⒸⓀⓎ◉ in Spring Framework and more
Wrong insertion code maybe?
источник

◉ⓁⓊⒸⓀⓎ◉ in Spring Framework and more
We don't know why u didn't able to insert where and what?
источник

VS

Vitaly Sirotkin in Spring Framework and more
◉ⓁⓊⒸⓀⓎ◉
We don't know why u didn't able to insert where and what?
Бля я ничего не понял из того что ты написал)))
источник

VP

Ved Prakash in Spring Framework and more
here is my controoler
источник

VP

Ved Prakash in Spring Framework and more
package controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import model.Users;
import repository.UserJpaRepository;

@RestController
@RequestMapping("/user")
public class UserController {

@Autowired
private UserJpaRepository userJpaRepostiory;

/* @RequestMapping(value = "/all", method=RequestMethod.GET) */
@GetMapping(value= "/all")
public List<Users>findAll(){
  return userJpaRepostiory.findAll();
}


@GetMapping(value= "/{name}")
public Users findByName(@PathVariable final String name) {
 return userJpaRepostiory.findByName(name);
}

@PostMapping(value= "/load")
public Users load(@RequestBody final Users users) {
 userJpaRepostiory.save(users);
 return userJpaRepostiory.findByName(users.getName());
}


}
источник

VP

Ved Prakash in Spring Framework and more
package com.springmain.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@EnableJpaRepositories
@SpringBootApplication
public class DemoApplication {

public static void main(String[] args) {
 SpringApplication.run(DemoApplication.class, args);
}

}
источник

VP

Ved Prakash in Spring Framework and more
package repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Component;

import model.Users;

@Component
public interface UserJpaRepository extends JpaRepository<Users, Long>
{

Users findByName(String name);

}
источник

VP

Ved Prakash in Spring Framework and more
here is my repository above
источник

◉ⓁⓊⒸⓀⓎ◉ in Spring Framework and more
Vitaly Sirotkin
Бля я ничего не понял из того что ты написал)))
Написал что мы не знаем почему он не может вставить и что именно он собирается вставлять и куда, главное что он понял))
источник

VP

Ved Prakash in Spring Framework and more
getter setter
источник

VP

Ved Prakash in Spring Framework and more
package model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
public class Users {

private Long id;
private String name;
private String teamName;
private Integer salary;

@Id
@GeneratedValue
public Long getId() {
 return id;
}
public void setId(Long id) {
 this.id = id;
}
public String getName() {
 return name;
}
public void setName(String name) {
 this.name = name;
}
public String getTeamName() {
 return teamName;
}
public void setTeamName(String teamName) {
 this.teamName = teamName;
}
public Integer getSalary() {
 return salary;
}
public void setSalary(Integer salary) {
 this.salary = salary;
}




}
источник

VS

Vitaly Sirotkin in Spring Framework and more
Ved Prakash
here is my repository above
You'd better show us your stack trace than code
источник

VP

Ved Prakash in Spring Framework and more
in my console it doesnot show any any error
источник

VP

Ved Prakash in Spring Framework and more
источник

VP

Ved Prakash in Spring Framework and more
источник