Giter VIP home page Giter VIP logo

backenda3sem3's Introduction

This project is meant as start code for projects and exercises given in Flow-1+2 (+3 using the security-branch) at http://cphbusiness.dk in the Study Program "AP degree in Computer Science"

Projects which are expected to use this start-code are projects that require all, or most of the following technologies:

  • JPA and REST
  • Testing, including database test
  • Testing, including tests of REST-API's
  • CI and CONTINUOUS DELIVERY

Flow 2 week 1

Preconditions

In order to use this code, you should have a local developer setup + a "matching" droplet on Digital Ocean as described in the 3. semester guidelines

Getting Started

This document explains how to use this code (build, test and deploy), locally with maven, and remotely with maven controlled by Github actions

JPA snippets

Setup in Intellij

  • open view->too windows->persistence
  • open the Database tab and create a new data source (remember to point to a database event though this is already written in the persistence unit. This is necessary in order to use the JPQL console)
  • in the persistence window right click the pu or an entity and choose "console"
  • write a jpql query in the console and execute it.

In netbeans it is much simpler

  • just right click the pu and choose: "Run JPQL query"

Create model in workbench (cannot be done from Intellij - No model designer yet)

  • file-> new model
  • dobbelclick the mydb icon and change to relevant database (create one first if needed)
  • click the Add Diagram icon
  • click the table icon in the left side panel and click in the squared area to insert new table
  • dobbelclick the new table and change name and add columns (remember to add a check mark in 'ai' for the primary key)
  • do the process again to add a second table
  • now in the panel choose the 'non identifying relationship' on to many
  • click first on the child table (the one that should hold the foreign key) and then on the parent. A new relationship was now added.
  • When done with designing - goto top menu: Database->forward engineer.
    • Check that all settings looks right and click continue
    • click continue again (no changes needed here)
    • Make sure the 'Export mysql table objects' is checked and Show filter to make sure that all your tables are in the 'objects to process' window -> click continue
    • Verify that the generated script looks right -> click continue
    • click close and open the database to see the new tables, that was just created.

create entities from database in Intellij (Persistence mappings)

  • From inside the Persistence window:
  • Right-click a persistence unit, point to Generate Persistence Mapping and select By Database Schema.
  • Select the
    • data source
    • package
    • tick tables to include
    • open tables to see columns and add the ones with mapped type: Collection and SomeEntity
    • click OK.

In netbeans it is much easier

  • Right click project name -> new -> persistence -> Entity classes From Database -> choose database connection from list -> add the tables you need -> Finish

backenda3sem3's People

Contributors

kd131 avatar capa2 avatar pantertanter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.