grails-domain-class

Accessing the data in db via Domain class in Controller via grails testing

筅森魡賤 提交于 2019-12-25 08:43:06
问题 def index() { //println params String params_key =params['key'] def c = get_value(params_key) def resp = ['key': params_key, 'value':c] render resp as JSON } private static hash_conv(String value) { def matches = Eval.me(value.replace(':','').replace('{','[').replace('=>',':').replace('#','//').replace('}',']')) return matches } private get_value(String key, default_value=null){ def app_preferences = get_preferences() def result = app_preferences[key] if (result == null) { result = default

How to access a user defined Grails Project Package Name using the domain class string name

雨燕双飞 提交于 2019-12-25 07:35:46
问题 What we are attempting to do is create one grails application with multiple package names. Each package name will represent a different business entity and functionality. Essentially multiple grails applications in one grails application project with each application being represented by having it's own package. We will then like to uniquely prefix the tables based on the package name without having to prefix the domain class names or use static mapping on every domain class. The

Creating a Domain Class with schema in Grails

孤街醉人 提交于 2019-12-25 05:37:04
问题 I am attempting to create a domain object in Grails. Previously I been using MySQL with single database, so my domain object is always easily defined. User domain maps to user table in the current database. This new project I am working requires me to use DB2, which when querying it, I must provide leading schema information. example: admin.user, Similar to database.table format. So now it is not so clear on how to create a Grails Domain object for this. Anyone have any reference or know how

grails domain class compiled output file keep changing without modification

半腔热情 提交于 2019-12-24 20:29:30
问题 I run "grails clean" first and then "grails war" to get the fresh distribution of the project. And the compiled output class(eg: Book.class) is keep changing after the above operations even without making any code modifications. It is strange or normal? Anyone can help me? Yang. 来源: https://stackoverflow.com/questions/46091270/grails-domain-class-compiled-output-file-keep-changing-without-modification

Best practice regarding the inclusion of id of domain model on equals implementation

走远了吗. 提交于 2019-12-24 15:21:41
问题 What is the best practice regarding implementation of equals of domain model in grails? Do we include the id field or just the business rule relevant fields? 回答1: Hibernate suggests that you include just the business key / candidate key in the equals implementation. Including the id field in the equals implementation can have negative consequences if you have generated id field. Hibernate assigns id only when saving the object (if you are using generated ids). Now for example, if your new

Grails 2.4.2 Domain will not save more than 8 fields

陌路散爱 提交于 2019-12-24 14:59:04
问题 I am receiving an arrayIndexOutOfBounds exception when I try ta save a new record in my Grails app. I have narrowed the problem down to only being able to save 8 fields. Here is my domain class: package nhvr class NhvrJourny { static constraints = { nhvrNo nullable:true journeyId nullable:true width nullable:true vLength nullable:true height nullable:true rearOverhang nullable:true } Long nhvrNo String journeyId String title BigDecimal width BigDecimal vLength BigDecimal height BigDecimal

How To Solve Grails Error Repeated column in mapping for entity? on Existing Postgresql Database

倖福魔咒の 提交于 2019-12-24 05:38:27
问题 Hi i have this following Domain in Grails class Customer { static mapping = { table 'customer' // version is set to false, because this isn't available by default for legacy databases version false id column:'customerid' //generator:'identity', } Long customerid Long customergroupid String username String password String name String street String city String province String postcode String country Date dateregistered String balance Long parentid String parentrebate String metapath Long

GORM Relations without dependent delete

爱⌒轻易说出口 提交于 2019-12-23 13:06:13
问题 I have two domain classes User and Node. The following conditions should hold. a User can have zero or one node a Node can have one to n User (it is always initialized with a User instance) if you delete a Node the User will not be deleted if you delete a User the reference in the Node will be deleted I tried: class User { Node node } class Node { // constructor Node(User user) { addToUsers(user) save() } hasMany = [users: User] } The former does not work. It does not work because when you

Grails: Foreign key as primary key?

核能气质少年 提交于 2019-12-23 05:57:08
问题 first of all i have to say that i have an existing database that it can not be modify (that´s why i am having this problem) I have two cases, the first one is this: In this case the id (primary key) must be a foreign key as well. The code that i put, it doesn´t work. class SbPEstadoComponente { static mapping = { table 'SB_P_ESTADO_COMPONENTE' version false idEstadoComponenteHxPEstado column:'ID_ESTADO_COMPONENTE' id column:'ID_ESTADO_COMPONENTE' } // Relation SbPDemora