Commit cab6f0ba by Patryk Czarnik

Jednak powrót do Spring Boot 2.7.6

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