Commit cab6f0ba by Patryk Czarnik

Jednak powrót do Spring Boot 2.7.6

parent 018736ed
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0</version> <version>2.7.6</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>com.example</groupId> <groupId>com.example</groupId>
......
...@@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import jakarta.persistence.EntityManager; import javax.persistence.EntityManager;
import jakarta.persistence.TypedQuery; import javax.persistence.TypedQuery;
import sklep.model.Product; import sklep.model.Product;
@Controller @Controller
......
...@@ -4,14 +4,15 @@ import java.util.List; ...@@ -4,14 +4,15 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import jakarta.persistence.EntityManager; import javax.persistence.EntityManager;
import jakarta.persistence.TypedQuery; import javax.persistence.TypedQuery;
import sklep.model.Product; import sklep.model.Product;
@Controller @Controller
...@@ -21,19 +22,11 @@ public class ProductController { ...@@ -21,19 +22,11 @@ public class ProductController {
private EntityManager em; private EntityManager em;
@GetMapping @GetMapping
@ResponseBody public String wszystkieProdukty(Model model) {
public String wszystkieProdukty() {
StringBuilder sb = new StringBuilder();
TypedQuery<Product> query = em.createNamedQuery("Product.findAll", Product.class); TypedQuery<Product> query = em.createNamedQuery("Product.findAll", Product.class);
List<Product> products = query.getResultList(); List<Product> products = query.getResultList();
for(Product product : products) { model.addAttribute("products", products);
sb.append("* produkt ") return "products";
.append(product.getProductName())
.append(" za cenę ")
.append(product.getPrice())
.append('\n');
}
return sb.toString();
} }
@GetMapping("/{id}") @GetMapping("/{id}")
......
package sklep.model; package sklep.model;
import java.io.Serializable; import java.io.Serializable;
import jakarta.persistence.*; import javax.persistence.*;
import java.util.List; import java.util.List;
......
package sklep.model; package sklep.model;
import java.io.Serializable; import java.io.Serializable;
import jakarta.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
......
package sklep.model; package sklep.model;
import java.io.Serializable; import java.io.Serializable;
import jakarta.persistence.*; import javax.persistence.*;
import java.math.BigDecimal; import java.math.BigDecimal;
......
package sklep.model; package sklep.model;
import java.io.Serializable; import java.io.Serializable;
import jakarta.persistence.*; import javax.persistence.*;
/** /**
* The primary key class for the order_products database table. * The primary key class for the order_products database table.
......
package sklep.model; package sklep.model;
import java.io.Serializable; import java.io.Serializable;
import jakarta.persistence.*; import javax.persistence.*;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment