Skip to content

Instantly share code, notes, and snippets.

@mahbub-shohag
Last active July 11, 2019 04:33
Show Gist options
  • Save mahbub-shohag/d0d274fc958676de40f7dfe9f2022b8a to your computer and use it in GitHub Desktop.
Save mahbub-shohag/d0d274fc958676de40f7dfe9f2022b8a to your computer and use it in GitHub Desktop.
-- curl -s "https://get.sdkman.io" | bash
-- source "$HOME/.sdkman/bin/sdkman-init.sh"
-- sdk install grails 2.5.6
Go to directory where you want to create grail application
-- grails create-app
-- give a name of the application
-- grails run-app
-- connect to mysql database
Datasource :
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
username: root
password: ""
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
//url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
url = "jdbc:mysql://localhost/inventory?useUnicode=yes&characterEncoding=UTF-8"
username = "root"
password = ""
}
}
Build Config
dependencies {
runtime 'mysql:mysql-connector-java:5.1.18'
}
--connect to oracle
------------------------
dataSource {
pooled = true
jmxExport = true
driverClassName = "oracle.jdbc.driver.OracleDriver"
dialect = org.hibernate.dialect.Oracle10gDialect
username = "SUERP"
password = "SoftRithmITBismillah601"
}
-----------------------------
dataSource {
dbCreate = ""
url = "jdbc:oracle:thin:@192.168.0.105:1521:xe"
logSql = true
}
-----------------------------
?? How to add field in grails domain and at the same time how to migrate it?
one to many relationship
-----------------------
static hasMany = [ registrations : Registration,
sponsors : Sponsor ]
# create grails domain : grails create-domain-class -> give name
# create grails controller : grails create-controller ->give domain name
# In controller def scffold = domainName will create all of the crud method and relevent views
Change Port In Grails in BuildConfig.groovy page
grails.server.port.http = 8090
## auto increment column add hibernate
CREATE SEQUENCE HIBERNATE_SEQUENCE
START WITH 1
MAXVALUE 9999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER
#Grails Closure to override class name#
#Change Dropdown display name in grails#
String toString(){
return this.name
}
#Template : grails install-
templates
=======================================================================
Controller
----------
return of action controller :
render :
return :
json return : render list as JSON
=======================================================================
=======================================================================
initially insert some test data
-------------------------------
=======================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment