Skip to content
This repository has been archived by the owner on Apr 9, 2022. It is now read-only.

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Simtay committed May 11, 2013
1 parent 413672b commit 3ae9320
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@
<primefaces-version>3.4.2</primefaces-version>
<primefaces-themes-artifact>afterwork</primefaces-themes-artifact>
<primefaces-themes-version>1.0.8</primefaces-themes-version>

<netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
</properties>
</project>
112 changes: 55 additions & 57 deletions src/main/java/com/nz/simplecrud/entity/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -1,57 +1,55 @@
package com.nz.simplecrud.entity;

import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
* Super Entity class
* @author Emre Simtay <[email protected]>
*/
@MappedSuperclass
public abstract class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}

@Override
public boolean equals(Object obj) {

if (obj == null){
return false;
}
else if (!(obj instanceof BaseEntity)){
return false;
}
else if (((BaseEntity) obj).id.equals(this.id)){
return true;
}
else{
return false;
}
}

@Override
public String toString() {
return "com.nz.simplecrud.entity[ id=" + id + " ]";
}

}
package com.nz.simplecrud.entity;

import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
* Super Entity class
*
* @author Emre Simtay <[email protected]>
*/
@MappedSuperclass
public abstract class BaseEntity implements Serializable {

private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}

@Override
public boolean equals(Object obj) {

if (obj == null) {
return false;
} else if (!(obj instanceof BaseEntity)) {
return false;
} else if (((BaseEntity) obj).id.equals(this.id)) {
return true;
} else {
return false;
}
}

@Override
public String toString() {
return "entity." + this.getClass() + "[ id=" + id + " ] ";
}
}
69 changes: 69 additions & 0 deletions src/main/resources/META-INF/Initial Population.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

INSERT INTO `simplecrud_db`.`address`
(`ID`, `CITY`, `COUNTRY`, `STREET`,`SUBURB`)
VALUES
('1', 'city', 'country', 'street', 'suburb'),
('2', 'city', 'country', 'street', 'suburb'),
('3', 'city', 'country', 'street', 'suburb'),
('4', 'city', 'country', 'street', 'suburb'),
('5', 'city', 'country', 'street', 'suburb'),
('6', 'city', 'country', 'street', 'suburb'),
('7', 'city', 'country', 'street', 'suburb'),
('8', 'city', 'country', 'street', 'suburb'),
('9', 'city', 'country', 'street', 'suburb'),
('10', 'city', 'country', 'street', 'suburb'),
('11', 'city', 'country', 'street', 'suburb'),
('12', 'city', 'country', 'street', 'suburb'),
('13', 'city', 'country', 'street', 'suburb');

INSERT INTO `simplecrud_db`.`role`
(`ID`, `ROLEDESC`, `ROLENAME`)
VALUES
('1', 'Administrator', 'Administrators'),
('2', 'Manager', 'Managers'),
('3', 'User', 'Users');

INSERT INTO `simplecrud_db`.`user`
(`ID`, `EMAIL`, `FIRSTNAME`, `LASTNAME`, `PASSWORD`, `USERNAME`, `ADDRESS_ID`)
VALUES
('1', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'admin', '1'),
('2', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user1', '2'),
('3', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user2', '3'),
('4', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user3', '4'),
('5', 'e-mail', 'name', 'surnamer', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user4', '5'),
('6', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user5', '6'),
('7', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user6', '7'),
('8', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user7', '8'),
('9', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user8', '9'),
('10', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user9', '10'),
('11', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user10', '11'),
('12', 'e-mail', 'name', 'surname', '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4', 'user11', '12'),
('13', 'e-mail', 'name', 'surname', '8cc7a4de25920211fb328c8b3e3f7ccadeff4a2073ba8a093ebf3a06ab828774', 'user12', '13');

INSERT INTO `simplecrud_db`.`user_roles`
(`Role_roleid`, `User_userid`)
VALUES
('1', '1'),
('3', '2'),
('3', '3'),
('3', '4'),
('3', '5'),
('3', '6'),
('3', '7'),
('3', '8'),
('3', '9'),
('3', '10'),
('3', '11'),
('3', '12'),
('3', '13');


CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost`
SQL SECURITY DEFINER VIEW `user_role_view`
AS select `simplecrud_db`.`user`.`USERNAME`
AS `username`,`simplecrud_db`.`user`.`PASSWORD`
AS `password`,`simplecrud_db`.`role`.`ROLENAME`
AS `rolename`
from ((`user_roles`
join `user` on((`simplecrud_db`.`user_roles`.`User_userid` = `simplecrud_db`.`user`.`ID`)))
join `role` on((`simplecrud_db`.`user_roles`.`Role_roleid` = `simplecrud_db`.`role`.`ID`)))
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="com.nz_war_1.0-SNAPSHOTPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/pro_mydb</jta-data-source>
<jta-data-source>jdbc/SimpleCRUD_JDBC</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
Expand Down

0 comments on commit 3ae9320

Please sign in to comment.