📄 index.xtp
字号:
<document> <header> <product>resin-ee</product> <title>Creating and Removing Entity Beans</title> <description> <p>Describes the basic create/remove api for persistent entities. </p></description> <type>tutorial</type> <tutorial-startpage>create</tutorial-startpage> </header> <body> <summary/><s1><p>Almost all applications need to add and remove entities from thedatabase. Although most database accesses are reads, eventually weneed to change the database. With Amber, you create a new instancewith the following steps:</p><ol><li>Instantiate the instance with "new"</li><li>Populate the values</li><li>Call the EntityManager ersist method</li></ol></s1><s1 title="Files in this tutorial"><deftable><tr><td><viewfile-link file="WEB-INF/resin-web.xml"/> </td><td>resin-web.xml configuration</td></tr><tr><td><viewfile-link file="WEB-INF/classes/META-INF/persistence.xml"/> </td><td>persistence.xml configuration</td></tr><tr><td><viewfile-link file="WEB-INF/classes/example/Course.java"/> </td><td>The course bean</td></tr><tr><td><viewfile-link file="WEB-INF/classes/example/CreateServlet.java"/> </td><td>The create servlet</td></tr></deftable></s1><s1 title="Database Schema"><p>The example uses the same database table as the previous basic example.</p><example title="create.sql">CREATE TABLE create_courses ( id BIGINT PRIMARY KEY auto_increment, course VARCHAR(250), instructor VARCHAR(250));</example></s1><s1 title="Client Servlet"><p>Clients create a new bean and populate the fields just likea normal Java object. The client adds the entry to the databaseby calling the EntityManager's <code>persist</code> method.</p><example title="Adding and Removing Courses">...divination = new Course("Divination", "Sybil Trelawney");_entityManager.persist(divination);..._entityManager.remove(divination);...</example></s1> </body></document>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -