Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Controlling column order when creating tables with ddl-generation
Controlling column order when creating tables with ddl-generation [message #388115] Mon, 25 May 2009 11:33 Go to next message
Eclipse UserFriend
I'm using EclipseLink with the "eclipselink.ddl-generation" property set
to "create-tables". The order of the columns in the created tables seems
random. I want the columns in a particular order - the order in which the
fields appear in the Entity class definition.

My database is PostgresQL.

Is there a way to tell EclipseLink to create the columns in the order in
the Entity class definition or some other way to specify column order?

Thanks.
Re: Controlling column order when creating tables with ddl-generation [message #388423 is a reply to message #388115] Mon, 25 May 2009 14:01 Go to previous messageGo to next message
Eclipse UserFriend
There is a method on ClassDescriptor in EclipseLink,
setShouldOrderMappings(), if you set this to false, you might get the
order you are looking for.

Otherwise, you could use your own script to create your tables, the order
the columns are declared in should not really matter.

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html
Re: Controlling column order when creating tables with ddl-generation [message #735928 is a reply to message #388423] Thu, 13 October 2011 02:50 Go to previous messageGo to next message
Eclipse UserFriend
Hello James,

In my application,I define an entity class and a class implements DescriptorCustomizer,


@Entity
@Table(name = "adapter")
@Customizer(OrderCustomizer.class)
public class AdapterRecord implements Comparable<AdapterRecord>, Serializable
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	private String name;
	
	private int serialNum;
	
	private boolean isRunnig;
	
	private String serverIp;

	@Temporal(TemporalType.TIMESTAMP)
	private Date startTime;
	
	private int test;
	private int test1;
	private int ptest;
	
	private String pIp;
	private String sIp;
	
	private int aTest;

......
}


public class OrderCustomizer implements DescriptorCustomizer
{
	@Override
	public void customize(ClassDescriptor descriptor)
	{
		descriptor.setShouldOrderMappings(false);

	}


}



I want the columns in a particular order - the order in which the
fields appear in the Entity class definition.

But when I run the application ,I got columns order :

index.php/fa/4248/0/

starttime,
id,
atest,
test1,
test,
name,
serverip,
isrunning,
serialnum,
pIp,
ptest,
sip

Could you give me some help ? Thanks a lot.

Boyd
  • Attachment: columns.JPG
    (Size: 51.96KB, Downloaded 973 times)

[Updated on: Thu, 13 October 2011 02:56] by Moderator

Re: Controlling column order when creating tables with ddl-generation [message #741962 is a reply to message #735928] Wed, 19 October 2011 23:49 Go to previous messageGo to next message
Eclipse UserFriend
Can someone help me?

Thanks for any suggestion.

Boyd.

[Updated on: Wed, 19 October 2011 23:50] by Moderator

Re: Controlling column order when creating tables with ddl-generation [message #741966 is a reply to message #735928] Wed, 19 October 2011 23:49 Go to previous message
Eclipse UserFriend
Can someone help me?

Thanks for any suggesion.

Boyd.
Previous Topic:what maven artefact for (DynamicJaxbContext with xsd) ...jaxb.dynamic.metadata.SchemaMetadata
Next Topic:Cached Ordered Lists have null inserted during 2nd update
Goto Forum:
  


Current Time: Wed Jul 23 09:59:13 EDT 2025

Powered by FUDForum. Page generated in 0.70856 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top