Support
Quality
Security
License
Reuse
kandi has reviewed mybatis-generator-core and discovered the below as its top functions. This is intended to give you an instant insight into mybatis-generator-core implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
QUESTION
why did not generate enableSelectByPrimaryKey when using mybatis generator
Asked 2021-Jul-10 at 12:32When I am using this command to generate mybatis xml file:
java -jar mybatis-generator-core-1.3.4.jar -configfile generatorConfig.xml -overwrite
everything works fine but finnaly i found the user mapper result file did not genreate SelectByPrimaryKey
function. this is part of my generate file config:
<table tableName="users"
enableCountByExample="true"
enableUpdateByExample="true"
enableDeleteByExample="true"
enableSelectByExample="true"
enableSelectByPrimaryKey="true"
enableUpdateByPrimaryKey="true"
selectByPrimaryKeyQueryId="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="JDBC" identity="true" />
</table>
my database is PostgreSQL 13. what should I do to fix it? This is my user table DML:
CREATE TABLE public.users (
id int8 NOT NULL GENERATED ALWAYS AS IDENTITY,
nickname varchar NULL,
avatar_url varchar NULL,
phone varchar NOT NULL,
updated_time int8 NOT NULL,
created_time int8 NOT NULL,
salt varchar NULL,
pwd varchar NULL,
sex int4 NULL,
level_type varchar NULL,
phone_region varchar NULL,
country_code int4 NULL,
user_status int4 NULL DEFAULT 1,
last_login_time int8 NULL,
first_login_time int8 NULL,
app_id int4 NOT NULL,
register_time int8 NULL,
apple_iap_product_id varchar NULL,
CONSTRAINT unique_phone UNIQUE (phone)
);
ANSWER
Answered 2021-Jul-10 at 12:29The DML you posted shows that the table doesn't have a primary key. You have two options.
You could define a primary key in the table by adding this to the create table statement:
create table public.users (
...
primary key (id)
);
Or, if you don't want to define a primary key in the database, you can use the "VirtualPrimaryKeyPlugin" in MyBatis Generator. See here for details: https://mybatis.org/generator/reference/plugins.html
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Find more information at:
Save this library and start creating your kit
See Similar Libraries in
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source