0

i am using jhipster 4.0.0 and i fisrt created two entity

@Entity
@Table(name = "organization")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Organization implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "orgname")
    private String orgname;

    @Column(name = "orgaddress")
    private String orgaddress;

    @OneToMany(mappedBy = "organization")
    @JsonIgnore
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    private Set<Branch> branches = new HashSet<>();

//geter()
//setter()

}

and

@Entity
@Table(name = "branch")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Branch implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "branchname")
    private String branchname;

    @Column(name = "branchaddress")
    private String branchaddress;

    @ManyToOne
    private Organization organization;

    //geter()
    //setter()

    }

these two working fine now i add new property called Active to organization entity like

>yo jhipster:entity organization
? Do you want to update the entity? This will replace the existing files for this entity, all your custom code will be overwritten Yes, add more fields and relationshi

================= Organization =================
Fields
orgname (String)
orgaddress (String)

Relationships
branch (Branch) one-to-many


Generating field #3

? Do you want to add a field to your entity? Yes
? What is the name of your field? active
? What is the type of your field? String
? Do you want to add validation rules to your field? No

================= Organization =================
Fields
orgname (String)
orgaddress (String)
active (String)

Relationships
branch (Branch) one-to-many


Generating field #4

? Do you want to add a field to your entity? No

================= Organization =================
Fields
orgname (String)
orgaddress (String)
active (String)

Relationships
branch (Branch) one-to-many


Generating relationships to other entities

? Do you want to add a relationship to another entity? No

================= Organization =================
Fields
orgname (String)
orgaddress (String)
active (String)

Relationships
branch (Branch) one-to-many



 conflict .jhipster\Organization.json
? Overwrite .jhipster\Organization.json? overwrite
    force .jhipster\Organization.json
 conflict src\main\resources\config\liquibase\changelog\20170209093838_added_entity_Organization.xml
? Overwrite src\main\resources\config\liquibase\changelog\20170209093838_added_entity_Organization.xml? overwrite
    force src\main\resources\config\liquibase\changelog\20170209093838_added_entity_Organization.xml
 conflict src\main\java\com\icarat\domain\Organization.java
? Overwrite src\main\java\com\icarat\domain\Organization.java? overwrite
    force src\main\java\com\icarat\domain\Organization.java
identical src\main\java\com\icarat\repository\OrganizationRepository.java
identical src\main\java\com\icarat\web\rest\OrganizationResource.java
identical src\main\java\com\icarat\service\OrganizationService.java
identical src\main\java\com\icarat\service\impl\OrganizationServiceImpl.java
 conflict src\main\java\com\icarat\service\dto\OrganizationDTO.java
? Overwrite src\main\java\com\icarat\service\dto\OrganizationDTO.java? overwrite
    force src\main\java\com\icarat\service\dto\OrganizationDTO.java
identical src\main\java\com\icarat\service\mapper\OrganizationMapper.java
 conflict src\test\java\com\icarat\web\rest\OrganizationResourceIntTest.java
? Overwrite src\test\java\com\icarat\web\rest\OrganizationResourceIntTest.java? do not overwrite
     skip src\test\java\com\icarat\web\rest\OrganizationResourceIntTest.java
identical src\main\resources\config\liquibase\master.xml
identical src\main\resources\ehcache.xml
 conflict src\main\webapp\app\entities\organization\organization.component.html
? Overwrite src\main\webapp\app\entities\organization\organization.component.html? do not overwrite
     skip src\main\webapp\app\entities\organization\organization.component.html
 conflict src\main\webapp\app\entities\organization\organization-detail.component.html
? Overwrite src\main\webapp\app\entities\organization\organization-detail.component.html? overwrite
    force src\main\webapp\app\entities\organization\organization-detail.component.html
 conflict src\main\webapp\app\entities\organization\organization-dialog.component.html
? Overwrite src\main\webapp\app\entities\organization\organization-dialog.component.html? do not overwrite

and when i run my project ./mvnw

it shows error like

liquibase.exception.ValidationFailedException: Validation Failed:
     1 change sets check sum
          classpath:config/liquibase/changelog/20170209093838_added_entity_Organization.xml::20170209093838-1::jhipster was: 7:2b47689e3924d85d502e6150230cd184 but is now: 7:74e4a48710ed8eaf27e2a0231f7d23a9

and i also i try all solution given by this also

How to modify existing entity generated with jhipster?

when i run mvn liquibase:diff after change i am geting like this

Settings
----------------------------
[INFO]     driver: com.mysql.jdbc.Driver
[INFO]     url: jdbc:mysql://localhost:3306/jhipster2
[INFO]     username: root
[INFO]     password: *****
[INFO]     use empty password: false
[INFO]     properties file: null
[INFO]     properties file will override? false
[INFO]     prompt on non-local database? true
[INFO]     clear checksums? false
[INFO]     changeLogFile: src/main/resources/config/liquibase/master.xml
[INFO]     context(s): null
[INFO]     label(s): null
[INFO]     referenceDriver: null
[INFO]     referenceUrl: hibernate:spring:com.icarat.domain?dialect=org.hibernate.dialect.MySQL5InnoDBDialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
[INFO]     referenceUsername: null
[INFO]     referencePassword: null
[INFO]     referenceDefaultSchema: null
[INFO]     diffChangeLogFile: src/main/resources/config/liquibase/changelog/20170209102144_changelog.xml
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.058 s
[INFO] Finished at: 2017-02-09T15:51:48+05:30
[INFO] Final Memory: 18M/49M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:diff (default-cli) on project jhipster-2: Error setting up or running Liquibase: liquibase.exception.DatabaseException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO) -> [Help 1]

can any one please help me

Community
  • 1
  • 1
VISHWANATH N P
  • 304
  • 1
  • 7
  • 11

2 Answers2

2

You need to set your database username & password in pom.xml for the liquibase-maven-plugin

user1735824
  • 111
  • 7
  • thanks mvn liquibase:diff is successfull build now .but when i run again its shows same error with anthor error like Description: Parameter 1 of constructor in com.icarat.service.impl.BranchServiceImpl required a bean of type 'com.icarat.service.mapper.BranchMapper' that could not be found Action:Consider defining a bean of type 'com.icarat.service.mapper.BranchMapper' in your configuration. .should i drop table and need to create once again – VISHWANATH N P Feb 09 '17 at 12:27
  • The Mapper error comes from MapStruct not being run, BranchMapperImpl is generated when you run `mvnw` or `mvnw compile` – Gaël Marziou Feb 09 '17 at 13:49
0

when we change database username & password in pom.xml for the liquibase-maven-plugin.

 <plugin>
                    <groupId>org.liquibase</groupId>
                    <artifactId>liquibase-maven-plugin</artifactId>
                    <version>${liquibase.version}</version>
                    <configuration>
                        <changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
                        <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
                        <driver>com.mysql.jdbc.Driver</driver>
                        <url>jdbc:mysql://localhost:3306/jhipsternew</url>
                        <defaultSchemaName>jhipsternew</defaultSchemaName>
                        <username>root</username>
                        <password>################</password>
                        <referenceUrl>hibernate:spring:com.icarat.domain?dialect=org.hibernate.dialect.MySQL5InnoDBDialect&amp;hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&amp;hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
                        <verbose>true</verbose>
                        <logging>debug</logging>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.javassist</groupId>
                            <artifactId>javassist</artifactId>
                            <version>3.18.2-GA</version>
                        </dependency>
                        <dependency>
                            <groupId>org.liquibase.ext</groupId>
                            <artifactId>liquibase-hibernate5</artifactId>
                            <version>${liquibase-hibernate5.version}</version>
                        </dependency>
                        <dependency>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-starter-data-jpa</artifactId>
                            <version>${project.parent.version}</version>
                        </dependency>
                        <dependency>
                            <groupId>javax.validation</groupId>
                            <artifactId>validation-api</artifactId>
                            <version>1.1.0.Final</version>
                        </dependency>
                    </dependencies>
                </plugin>

after that we have to run

./mvnw liquibase:clearCheckSums



./mvn liquibase:diff

after that new "change log" is created in our src/main/resources/config/liquibase/changelog directory. The files in that directory are prefixed by their creation date (in yyyyMMddHHmmss format), and then have a title describing what they do. For example, 20141006152300_added_price_to_product.xml is a good name. Add this "change log" file in your src/main/resources/config/liquibase/master.xml file, so it is applied the next time you run your application If you want more information on using Liquibase

VISHWANATH N P
  • 304
  • 1
  • 7
  • 11
  • Removing classpath seems a bad idea, I can't understand how your app will be able to find your Liquibase migration at startup when packaged as a war. Have you tested it in prod profile? – Gaël Marziou Feb 09 '17 at 13:54
  • You don't need to run `./mvw liquibase:update` the migrations are executed by your app when it starts up, this is why `classpath:` is required. – Gaël Marziou Feb 09 '17 at 14:36